Julia Flux error: SGD optimiser is undefined

Julia Flux error: SGD optimiser is undefined

我想在 Flux 中使用 SGD 优化器,如 Deep Learning with Flux.jl 的 Julia Academy 教程中所示。 This 他们提供的使用 SGD 优化器的笔记本:

opt = SGD(params(model))

但是当我 运行 SGD 我得到:

ERROR: UndefVarError: SGD not defined

这是我 运行 ?SGD:

时的输出
search: SGD AMSGrad Signed signed Unsigned unsigned sigmoid issetgid logsigmoid StringIndexError isassigned significand

Couldn't find SGD
Perhaps you meant SGD, Set, Sys, GC, Some, sec, sin, sum, LSTM, csc, esc, isa, ans, abs, cis, cos, eps, ARGS, Pkg, GRU, RNN, cpu, elu, f32, f64, gpu, σ, !, !=, !== or %
  No documentation found.

  Binding SGD does not exist.

如您所见,也许您的意思是行中仍然显示 SGD。

当我 运行 本教程中还显示的其他优化器(例如 ADAM)时,我没有收到错误。我正在使用 Flux v0.10.0

本教程使用 Flux 的过时版本。

在 Flux v0.10.0 版本中,Flux 弃用了 SGD,取而代之的是 Descent,后者只是标准梯度下降算法的更优化版本。

有关 Descent 优化器的更多信息,请参阅 documentation

另请注意,Flux 不再需要将 params(model) 传递给优化器,而是在训练时将其作为单独的参数。

# New Way
Flux.train!(loss, params(model), data, optimizer)