@Mariana I do not know about the early stopping, but for batch size, I recommend you to use DataLoader (in Flux.Data). With the parameters batchsize, and shuffle it is very simple to use:
data = Flux.Data.DataLoader(X, Y, batchsize=32, shuffle=true)
opt = ADAM()
loss(x, y) = Flux.mse(model(x), y)
ps = Flux.params(model)
evalcb() = @show loss(X,Y)
for epoch in 1:8
println("Epoch $epoch")
time = @elapsed train!(loss, ps, data, opt, cb=throttle(evalcb, 3))
println("Echo $epoch: $time secs")
@show epoch, loss(X,Y)
end
The code is an example, it is not complete.
If you have more problems, do not hesitate in ask again.