Skip to content

ImageClassifier with ExponentialLRDecay: metrics not updated/calculated during validation #4807

@gartangh

Description

@gartangh

System information

  • OS version: Windows 10 Pro 18363
  • .NET Version: Core 2.1
  • Platform: x64
  • ML.NET version: 0.15-preview

Issue

  • What did you do?
    I am trying to train an image classifier that makes use of ExponentialLRDecay.
    I would like to see the metrics for training and validation for each epoch.

    var options = new ImageClassificationTrainer.Options()
    {
      LearningRateScheduler = new ExponentialLRDecay(),
      ValidationSetFraction = 0.1f,
      MetricsCallback = (metrics) => Console.WriteLine(metrics  + $"   CrossEntropy: {metrics.Train.CrossEntropy}, LearningRate: {metrics.Train.LearningRate})
    };
    var model = mlContext.MulticlassClassification.Trainers.ImageClassification(options);

    (I added + $" CrossEntropy: {metrics.Train.CrossEntropy}, LearningRate: {metrics.Train.LearningRate}", because the crossentropy and learning rate are not printed by default for the validation set.)

  • What happened?

    • The learning rate is not updated for the validation set (seen on every even row in the image).
    • The cross-entropy is not calculated for the validation set (seen on every even row in the image).
    • The learning rate is not updated after the second epoch like the default value of 2 for numEpochsPerDecay in ExponentialLRDecay(), but after the first instead (seen on the third row in the image). After that, the learning rate is correctly updated every 2 epochs. I'm not sure if this is the expected behavior.

    image

  • What did you expect?

    • I expected a decaying learning rate in the validation step, equal to the one in the training step.
    • I expected the cross-entropy to be calculated in the validation step. The model with the highest Accuracy and lowest CrossEntropy are the best, so if 2 models perform equally well in terms of accuracy, the one with the lowest cross-entropy on the validation set should be picked.
    • Further, I expected the learning rate to start decaying after the 2nd epoch.

Metadata

Metadata

Assignees

Labels

P1Priority of the issue for triage purpose: Needs to be fixed soon.bugSomething isn't workingimageBugs related image datatype tasks

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions