mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-06-11 12:43:17 +08:00
Merge pull request #978 from stweil/lstm
LSTMTrainer: Catch empty vectors
This commit is contained in:
commit
2b854e3749
@ -918,6 +918,10 @@ bool LSTMTrainer::SaveTrainingDump(SerializeAmount serialize_amount,
|
|||||||
// Reads previously saved trainer from memory.
|
// Reads previously saved trainer from memory.
|
||||||
bool LSTMTrainer::ReadTrainingDump(const GenericVector<char>& data,
|
bool LSTMTrainer::ReadTrainingDump(const GenericVector<char>& data,
|
||||||
LSTMTrainer* trainer) {
|
LSTMTrainer* trainer) {
|
||||||
|
if (data.size() == 0) {
|
||||||
|
tprintf("Warning: data size is zero in LSTMTrainer::ReadTrainingDump\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return trainer->ReadSizedTrainingDump(&data[0], data.size());
|
return trainer->ReadSizedTrainingDump(&data[0], data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1298,8 +1302,9 @@ STRING LSTMTrainer::UpdateErrorGraph(int iteration, double error_rate,
|
|||||||
if (error_rate < best_error_rate_) {
|
if (error_rate < best_error_rate_) {
|
||||||
// This is a new (global) minimum.
|
// This is a new (global) minimum.
|
||||||
if (tester != NULL) {
|
if (tester != NULL) {
|
||||||
result = tester->Run(worst_iteration_, worst_error_rates_,
|
if (worst_model_data_.size() != 0)
|
||||||
worst_model_data_, CurrentTrainingStage());
|
result = tester->Run(worst_iteration_, worst_error_rates_,
|
||||||
|
worst_model_data_, CurrentTrainingStage());
|
||||||
worst_model_data_.truncate(0);
|
worst_model_data_.truncate(0);
|
||||||
best_model_data_ = model_data;
|
best_model_data_ = model_data;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user