如何指定我的模型应该在 Flux.jl 中训练的纪元数

How to specify the number of epoch's my model should train for in Flux.jl

我知道我希望根据我在其他框架和以前的模型中进行的一些模拟测试,让我的模型训练 200 个纪元。我如何指定我的模型应该在 Flux.jl 中训练的时期数?

Flux 提供了一个名为 @epochs 的便捷宏,可以按如下方式使用:

julia> using Flux: @epochs

julia> Flux.@epochs 2 println("hello")
[ Info: Epoch 1
hello
[ Info: Epoch 2
hello

或者在我们的训练循环中:

julia> using Flux: @epochs

julia> @epochs 2 Flux.train!(...)
# Train for two epochs

您可以在此处的 Flux.jl 文档中找到更多信息:https://fluxml.ai/Flux.jl/stable/training/training/