lstm_recode_test.cc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // (C) Copyright 2017, Google Inc.
  2. // Licensed under the Apache License, Version 2.0 (the "License");
  3. // you may not use this file except in compliance with the License.
  4. // You may obtain a copy of the License at
  5. // http://www.apache.org/licenses/LICENSE-2.0
  6. // Unless required by applicable law or agreed to in writing, software
  7. // distributed under the License is distributed on an "AS IS" BASIS,
  8. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. // See the License for the specific language governing permissions and
  10. // limitations under the License.
  11. #include "lstm_test.h"
  12. namespace tesseract {
  13. // Tests that training with unicharset recoding learns faster than without,
  14. // for Korean. This test is split in two, so it can be run sharded.
  15. TEST_F(LSTMTrainerTest, RecodeTestKorBase) {
  16. // A basic single-layer, bi-di 1d LSTM on Korean.
  17. SetupTrainer("[1,1,0,32 Lbx96 O1c1]", "kor-full", "kor/kor.unicharset",
  18. "kor.Arial_Unicode_MS.exp0.lstmf", false, true, 5e-4, false, "kor");
  19. double kor_full_err = TrainIterations(kTrainerIterations * 2);
  20. EXPECT_LT(kor_full_err, 88);
  21. // EXPECT_GT(kor_full_err, 85);
  22. LOG(INFO) << "********** Expected < 88 ************\n";
  23. }
  24. TEST_F(LSTMTrainerTest, RecodeTestKor) {
  25. // A basic single-layer, bi-di 1d LSTM on Korean.
  26. SetupTrainer("[1,1,0,32 Lbx96 O1c1]", "kor-recode", "kor/kor.unicharset",
  27. "kor.Arial_Unicode_MS.exp0.lstmf", true, true, 5e-4, false, "kor");
  28. double kor_recode_err = TrainIterations(kTrainerIterations);
  29. EXPECT_LT(kor_recode_err, 60);
  30. LOG(INFO) << "********** Expected < 60 ************\n";
  31. }
  32. // Tests that the given string encodes and decodes back to the same
  33. // with both recode on and off for Korean.
  34. TEST_F(LSTMTrainerTest, EncodeDecodeBothTestKor) {
  35. TestEncodeDecodeBoth("kor", "한국어 위키백과에 오신 것을 환영합니다!");
  36. }
  37. } // namespace tesseract.