fb15k237.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. #
  3. # copyright (c) 2017-present, facebook, inc.
  4. # all rights reserved.
  5. #
  6. # this source code is licensed under the MIT license found in the
  7. # license file in the root directory of this source tree.
  8. #
  9. # script for FB15k237
  10. DIR=data/Release/
  11. FASTTEXTDIR=../../
  12. # compile
  13. pushd $FASTTEXTDIR
  14. make opt
  15. popd
  16. ft=${FASTTEXTDIR}/fasttext
  17. g++ -std=c++0x eval.cpp -o eval
  18. ## Train model and test it on validation:
  19. pred=data/fb237pred
  20. model=data/fb15k237
  21. dim=50
  22. epoch=10
  23. neg=500
  24. echo "---- train ----"
  25. $ft supervised -input $DIR/ft_train.txt \
  26. -dim $dim -epoch $epoch -output ${model} -lr .2 -thread 20 -loss ns -neg $neg -minCount 0
  27. echo "computing filtered hit@10..."
  28. $ft predict ${model}.bin $DIR/ft_test.txt 20000 > $pred
  29. ./eval $pred ${DIR}/ft_test.txt $DIR/ft_full.txt 10 | awk '{if(NR==2) print "filtered hit@10="$2}'
  30. echo "---- train+val ----"
  31. $ft supervised -input $DIR/ft_valid+train.txt \
  32. -dim ${dim} -epoch ${dim} -output ${model} -lr .2 -thread 20 -loss ns -neg ${neg} -minCount 0
  33. echo "computing filtered hit@10..."
  34. $ft predict ${model}.bin $DIR/ft_test.txt 20000 > $pred
  35. ./eval $pred ${DIR}/ft_test.txt $DIR/ft_full.txt 10 | awk '{if(NR==2) print "filtered hit@10="$2}'