Configure the network trainer, then train only with the prepared training subset.
import deepnetts.net.train.opt.OptimizerType;
neuralNet.getTrainer()
.setStopEpochs(300)
.setLearningRate(0.001f)
.setOptimizer(OptimizerType.ADAM)
.setShuffle(true);
neuralNet.train(trainingSet);
| Setting | Purpose |
|---|---|
setStopEpochs(...) |
Maximum number of passes over the training data |
setLearningRate(...) |
Size of each parameter update |
setOptimizer(...) |
Algorithm used to update model parameters |
setShuffle(true) |
Changes sample order between epochs |
These values are starting points, not universal defaults. A model that does not learn may need a different learning rate, architecture, preprocessing choice, or more training.
For a larger dataset, enable batches explicitly:
neuralNet.getTrainer()
.setStopEpochs(50)
.setLearningRate(0.001f)
.setOptimizer(OptimizerType.SGD)
.setBatchMode(true)
.setBatchSize(64)
.setShuffle(true);
neuralNet.train(trainingSet);
CNNs use the same trainer API, but image batches consume more memory and each epoch usually takes longer than it does for a small tabular model:
network.getTrainer()
.setStopEpochs(20)
.setLearningRate(0.001f)
.setOptimizer(OptimizerType.ADAM)
.setBatchMode(true)
.setBatchSize(8)
.setShuffle(true);
network.train(trainingSet);
Start with a batch size that fits available memory. Compare training and held-out metrics across epochs; a successful smoke test confirms that the pipeline runs, but one epoch is not evidence that the CNN has converged.
Training can also stop when it reaches a configured error:
neuralNet.getTrainer()
.setStopError(0.03f)
.setStopEpochs(350)
.setLearningRate(0.001f)
.setOptimizer(OptimizerType.ADAM);
Keep an epoch limit even when using an error target so a run cannot continue indefinitely.
testSet invalidates the later evaluation.testSet prevents a clean held-out evaluation.One epoch is one complete pass through the training dataset.
A fixed seed makes initialization and data ordering reproducible enough to compare repeated development runs.
Was this helpful?
Thank you!