facebookresearch / StarSpace

Learning embeddings for classification, retrieval and ranking.
MIT License
3.94k stars 531 forks source link

Removing compiler warnings noted in #181 #184

Closed jwijffels closed 6 years ago

jwijffels commented 6 years ago

This is attempt to make compiler messages noted in issue #181 to disappear. Can you review. Especially the commenting out of Real negSim = (std::numeric_limits<Real>::min)(); in src/model.cpp

jwijffels commented 6 years ago

I've removed code on 3 places where the variable was unused. I also commented out the line in src/model.cpp where it says: Real negSim = (std::numeric_limits<Real>::min)(); as the compiler said it is not used. Can you validate this as later on you seem to be using this but apparently the compiler mentions it is unused code.

ledw commented 6 years ago

@jwijffels Looks good. If you have not already, could you make sure all tests passes and the examples scripts under /examples gives similar results? You don't need to run all the examples, just pick one, i.e.: /examples/classification_ag_news.sh

jwijffels commented 6 years ago

I'm unfamiliar with that googletest framework, I'm developing on Windows. This is what I get if I do makeand make test on a pretty old Ubuntu machine and if I run examples/classification_ag_news.sh Does that look fine?

jwijffels@bnosac:~/StarSpace$ make
g++ -pthread -std=gnu++11 -O3 -funroll-loops -g -c src/utils/normalize.cpp
g++ -pthread -std=gnu++11 -O3 -funroll-loops -g -c src/dict.cpp
g++ -pthread -std=gnu++11 -O3 -funroll-loops -g -c src/utils/args.cpp
g++ -pthread -std=gnu++11 -O3 -funroll-loops -I/usr/local/bin/boost_1_63_0/ -g -c src/proj.cpp
g++ -pthread -std=gnu++11 -O3 -funroll-loops -I/usr/local/bin/boost_1_63_0/ -g -c src/parser.cpp -o parser.o
g++ -pthread -std=gnu++11 -O3 -funroll-loops -g -c src/data.cpp -o data.o
g++ -pthread -std=gnu++11 -O3 -funroll-loops -I/usr/local/bin/boost_1_63_0/ -g -c src/model.cpp
g++ -pthread -std=gnu++11 -O3 -funroll-loops -I/usr/local/bin/boost_1_63_0/ -g -c src/starspace.cpp
g++ -pthread -std=gnu++11 -O3 -funroll-loops -I/usr/local/bin/boost_1_63_0/ -g -c src/doc_parser.cpp -o doc_parser.o
g++ -pthread -std=gnu++11 -O3 -funroll-loops -g -c src/doc_data.cpp -o doc_data.o
g++ -pthread -std=gnu++11 -O3 -funroll-loops -g -c src/utils/utils.cpp -o utils.o
g++ -pthread -std=gnu++11 -O3 -funroll-loops normalize.o dict.o args.o proj.o parser.o data.o model.o starspace.o doc_parser.o doc_data.o utils.o -I/usr/local/bin/boost_1_63_0/ -g src/main.cpp -o starspace
jwijffels@bnosac:~/StarSpace$ make test
g++ -pthread -std=gnu++11 -I/usr/local/bin/boost_1_63_0/ -Ihome/jwijffels/googletest/googletest/include -g -c src/test/matrix_test.cpp
g++ -isystem /home/jwijffels/googletest/googletest/include -I/home/jwijffels/googletest/googletest -pthread -std=gnu++11 -c \
            /home/jwijffels/googletest/googletest/src/gtest-all.cc
g++ -isystem /home/jwijffels/googletest/googletest/include -I/home/jwijffels/googletest/googletest -pthread -std=gnu++11 -c \
            /home/jwijffels/googletest/googletest/src/gtest_main.cc
ar rv gtest_main.a gtest-all.o gtest_main.o
ar: creating gtest_main.a
a - gtest-all.o
a - gtest_main.o
g++ -isystem /home/jwijffels/googletest/googletest/include -pthread -std=gnu++11 -lpthread matrix_test.o gtest_main.a -o matrix_test
matrix_test.o: In function `__static_initialization_and_destruction_0':
/home/jwijffels/StarSpace/src/test/matrix_test.cpp:15: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
/home/jwijffels/StarSpace/src/test/matrix_test.cpp:37: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
/home/jwijffels/StarSpace/src/test/matrix_test.cpp:55: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
matrix_test.o: In function `testing::AssertionResult testing::internal::CmpHelperFloatingPointEQ<float>(char const*, char const*, float, float)':
/usr/include/gtest/gtest.h:1585: undefined reference to `testing::internal::EqFailure(char const*, char const*, testing::internal::String const&, testing::internal::String const&, bool)'
matrix_test.o: In function `testing::AssertionResult testing::internal::CmpHelperEQ<unsigned long, int>(char const*, char const*, unsigned long const&, int const&)':
/usr/include/gtest/gtest.h:1337: undefined reference to `testing::internal::EqFailure(char const*, char const*, testing::internal::String const&, testing::internal::String const&, bool)'
collect2: error: ld returned 1 exit status
make: *** [matrix_test] Error 1
jwijffels@bnosac:~/StarSpace$ ./examples/classification_ag_news.sh
Downloading dataset ag_news
Compiling StarSpace
g++ -pthread -std=gnu++11 -O3 -funroll-loops normalize.o dict.o args.o proj.o parser.o data.o model.o starspace.o doc_parser.o doc_data.o utils.o -I/usr/local/bin/boost_1_63_0/ -g src/main.cpp -o starspace
Start to train on ag_news data:
Arguments:
lr: 0.01
dim: 10
epoch: 5
maxTrainTime: 8640000
validationPatience: 10
saveEveryEpoch: 0
loss: hinge
margin: 0.05
similarity: dot
maxNegSamples: 3
negSearchLimit: 5
thread: 20
minCount: 1
minCountLabel: 1
label: __label__
ngrams: 1
bucket: 2000000
adagrad: 0
trainMode: 0
fileFormat: fastText
normalizeText: 0
dropoutLHS: 0
dropoutRHS: 0
Start to initialize starspace model.
Build dict from input file : /tmp/starspace/data/ag_news.train
Read 5M words
Number of words in dictionary:  95811
Number of labels in dictionary: 4
Loading data from file : /tmp/starspace/data/ag_news.train
Total number of examples loaded : 120000
Initialized model weights. Model size :
matrix : 95815 10
Training epoch 0: 0.01 0.002
Epoch: 100.0%  lr: 0.008000  loss: 0.007073  eta: <1min   tot: 0h0m3s  (20.0%)
 ---+++                Epoch    0 Train error : 0.00654415 +++--- ☃
Training epoch 1: 0.008 0.002
Epoch: 100.0%  lr: 0.006000  loss: 0.004257  eta: <1min   tot: 0h0m6s  (40.0%)
 ---+++                Epoch    1 Train error : 0.00400490 +++--- ☃
Training epoch 2: 0.006 0.002
Epoch: 100.0%  lr: 0.004000  loss: 0.003456  eta: <1min   tot: 0h0m9s  (60.0%)
 ---+++                Epoch    2 Train error : 0.00341031 +++--- ☃
Training epoch 3: 0.004 0.002
Epoch: 100.0%  lr: 0.002017  loss: 0.002651  eta: <1min   tot: 0h0m12s  (80.0%)
 ---+++                Epoch    3 Train error : 0.00292373 +++--- ☃
Training epoch 4: 0.002 0.002
Epoch: 100.0%  lr: 0.000050  loss: 0.002237  eta: <1min   tot: 0h0m15s  (100.0%)
 ---+++                Epoch    4 Train error : 0.00261122 +++--- ☃
Saving model to file : /tmp/starspace/models/ag_news
Saving model in tsv format : /tmp/starspace/models/ag_news.tsv
Start to evaluate trained model:
Arguments:
lr: 0.01
dim: 10
epoch: 5
maxTrainTime: 8640000
validationPatience: 10
saveEveryEpoch: 0
loss: hinge
margin: 0.05
similarity: dot
maxNegSamples: 10
negSearchLimit: 50
thread: 10
minCount: 1
minCountLabel: 1
label: __label__
ngrams: 1
bucket: 2000000
adagrad: 1
trainMode: 0
fileFormat: fastText
normalizeText: 0
dropoutLHS: 0
dropoutRHS: 0
Start to load a trained starspace model.
STARSPACE-2017-2
Initialized model weights. Model size :
matrix : 95815 10
Model loaded.
Loading data from file : /tmp/starspace/data/ag_news.test
Total number of examples loaded : 7600
------Loaded model args:
Arguments:
lr: 0.01
dim: 10
epoch: 5
maxTrainTime: 8640000
validationPatience: 10
saveEveryEpoch: 0
loss: hinge
margin: 0.05
similarity: dot
maxNegSamples: 3
negSearchLimit: 5
thread: 10
minCount: 1
minCountLabel: 1
label: __label__
ngrams: 1
bucket: 2000000
adagrad: 1
trainMode: 0
fileFormat: fastText
normalizeText: 0
dropoutLHS: 0
dropoutRHS: 0
Predictions use 4 known labels.
Evaluation Metrics :
hit@1: 0.918158 hit@10: 1 hit@20: 1 hit@50: 1 mean ranks : 1.10118 Total examples : 7600
ledw commented 6 years ago

@jwijffels the test seems to complain about some error, the ag_news example looks fine.

jwijffels commented 6 years ago

thanks!