Skip to content

Commit 36ad59b

Browse files
jjYBdx4ILjjYBdx4IL
authored andcommitted
fix fann_train_on_file and fann_cascadetrain_on_file to set at least ann->errno_f if reading training data from file failed
1 parent d71d547 commit 36ad59b

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

examples/steepness_train.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ void train_on_steepness_file(struct fann *ann, char *filename,
2929
unsigned int i;
3030

3131
struct fann_train_data *data = fann_read_train_from_file(filename);
32+
if(data == NULL)
33+
{
34+
ann->errno_f = FANN_E_CANT_READ_TD;
35+
return;
36+
}
3237

3338
if(epochs_between_reports)
3439
{

src/fann_cascade.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ FANN_EXTERNAL void FANN_API fann_cascadetrain_on_file(struct fann *ann, const ch
134134

135135
if(data == NULL)
136136
{
137+
ann->errno_f = FANN_E_CANT_READ_TD;
137138
return;
138139
}
139140
fann_cascadetrain_on_data(ann, data, max_neurons, neurons_between_reports, desired_error);

src/fann_train_data.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ FANN_EXTERNAL void FANN_API fann_train_on_file(struct fann *ann, const char *fil
306306

307307
if(data == NULL)
308308
{
309+
ann->errno_f = FANN_E_CANT_READ_TD;
309310
return;
310311
}
311312
fann_train_on_data(ann, data, max_epochs, epochs_between_reports, desired_error);

0 commit comments

Comments
 (0)