quantization-results.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2016-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. # This script applies quantization to the models from Table 1 in:
  10. # Bag of Tricks for Efficient Text Classification, arXiv 1607.01759, 2016
  11. set -e
  12. DATASET=(
  13. ag_news
  14. sogou_news
  15. dbpedia
  16. yelp_review_polarity
  17. yelp_review_full
  18. yahoo_answers
  19. amazon_review_full
  20. amazon_review_polarity
  21. )
  22. # These learning rates were chosen by validation on a subset of the training set.
  23. LR=( 0.25 0.5 0.5 0.1 0.1 0.1 0.05 0.05 )
  24. RESULTDIR=result
  25. DATADIR=data
  26. echo 'Warning! Make sure you run the classification-results.sh script before this one'
  27. echo 'Otherwise you can expect the commands in this script to fail'
  28. for i in {0..7}
  29. do
  30. echo "Working on dataset ${DATASET[i]}"
  31. ../../fasttext quantize -input "${DATADIR}/${DATASET[i]}.train" \
  32. -output "${RESULTDIR}/${DATASET[i]}" -lr "${LR[i]}" \
  33. -thread 4 -qnorm -retrain -epoch 5 -cutoff 100000 > /dev/null
  34. ../../fasttext test "${RESULTDIR}/${DATASET[i]}.ftz" \
  35. "${DATADIR}/${DATASET[i]}.test"
  36. done