-
-
Save mdfarragher/ec5c533fd5aa1e426d51d6d39af32815 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// train one epoch on batches | |
loss[epoch] = 0.0; | |
trainingError[epoch] = 0.0; | |
batchCount = 0; | |
training_data.Batch(batchSize, (data, begin, end) => | |
{ | |
// get the current batch | |
var featureBatch = features.GetSequenceBatch(sequenceLength, training_data, begin, end); | |
var labelBatch = labels.GetBatch(training_labels, begin, end); | |
// train the network on the batch | |
var result = trainer.TrainBatch( | |
new[] { | |
(features, featureBatch), | |
(labels, labelBatch) | |
}, | |
false | |
); | |
loss[epoch] += result.Loss; | |
trainingError[epoch] += result.Evaluation; | |
batchCount++; | |
}); | |
// show results | |
loss[epoch] /= batchCount; | |
trainingError[epoch] /= batchCount; | |
Console.Write($"{epoch}\t{loss[epoch]:F3}\t{trainingError[epoch]:F3}\t"); | |
// testing code goes here... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment