Skip to content

Commit 7153036

Browse files
committed
Fix bug with second training with no changes causing error
1 parent c0cdc2c commit 7153036

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

+ic/Model.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ function train(this)
339339
% preprocessing
340340
this.TrainingOptions.ValidationData = ...
341341
augmentedImageDatastore(networkInputSize(1:2), ...
342-
this.TrainingOptions.ValidationData, ...
342+
this.ValidationData, ...
343343
colorPreprocessing=colorPreprocessing);
344344

345345
[this.TrainedNetwork, this.TrainingResults] = trainnet( ...

test/unit/tModel.m

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function canSetTrainingOptions(test)
204204
test.verifyEqual(model.TrainingOptions.MaxEpochs, 17);
205205
end
206206

207-
function trainsNetworK(test)
207+
function trainsNetwork(test)
208208
% We should be able to train the network.
209209

210210
model = test.createSpecimen();
@@ -219,6 +219,22 @@ function trainsNetworK(test)
219219
test.verifyNotEmpty(model.TrainedNetwork);
220220
end
221221

222+
function secondTrainingSuccessful(test)
223+
% Training the model twice with no setting changes should work
224+
% as intended.
225+
226+
model = test.createSpecimen();
227+
test.importTestData(model);
228+
model.setAugmentations(RandRotation=[-5 5]);
229+
model.setNetworkFromPretrained("squeezenet");
230+
test.configureModelForFastTraining(model);
231+
232+
model.train();
233+
model.train();
234+
235+
test.verifyNotEmpty(model.TrainedNetwork);
236+
end
237+
222238
function predictsOnImage(test)
223239
% We should be able to perform inference on a single new image.
224240

0 commit comments

Comments
 (0)