Let's look at a simple training example. In FluxTraining.jl, a Learner
holds all state necessary for training. To get started, you need
- a model
- training and validation data iterators
- a loss function; and
- an optimizer
First we define the necessary pieces:
model = ...
traindata, valdata = ...
lossfn = Flux.Losses.mse
opt = Flux.ADAM(0.01)
Then we construct a Learner
:
learner = Learner(model, lossfn; data=(traindata, valdata))
And train for 10 epochs:
fit!(learner, 10)