ERROR: UndefVarError: `ADAM` not defined in `Main` in flux

Hi, i get this error when try to using flux
julia> using Pkg

julia> Pkg.add(“Flux”)
Resolving package versions…
No Changes to C:\Users\lbtvi\.julia\environments\v1.11\Project.toml
No Changes to C:\Users\lbtvi\.julia\environments\v1.11\Manifest.toml

julia> Pkg.add(“Images”)
Resolving package versions…
No Changes to C:\Users\lbtvi\.julia\environments\v1.11\Project.toml
No Changes to C:\Users\lbtvi\.julia\environments\v1.11\Manifest.toml

julia> Pkg.add(“BSON”)
Resolving package versions…
No Changes to C:\Users\lbtvi\.julia\environments\v1.11\Project.toml
No Changes to C:\Users\lbtvi\.julia\environments\v1.11\Manifest.toml

julia> using Flux

julia> using Flux.Optimise
julia> using BSON

julia> using Images

julia> # Khai báo biến cho tối ưu hóa

julia> opt = ADAM(0.001) # Khai báo tối ưu hóa ADAM với learning rate là 0.001
ERROR: UndefVarError: ADAM not defined in Main
Suggestion: check for spelling errors or missing imports.
Hint: a global variable of this name may be made accessible by importing Optimisers in the current active module Main
Stacktrace:
[1] top-level scope
@ REPL[10]:1

julia>

julia> # Huấn luyện mô hình

julia> @epochs 10 Flux.train!(loss, params(model), data, opt) # Huấn luyện mô hình
ERROR: LoadError: UndefVarError: @epochs not defined in Main
Suggestion: check for spelling errors or missing imports.
in expression starting at REPL[12]:1

julia> using Flux: @epochs # Nhập @epochs từ Flux
WARNING: could not import Flux.@epochs into Main

julia>
How can i fix this, thanks alot

This means you are following a guide for a very old version of Flux. Can you provide a link?

The current version spells this Adam, but also no longer has @epochs, and strongly discourages Flux.params(model). It should look more like this.

1 Like

Hello, I’ve encountered the same issue. Have you resolved it?
Here is my code.

opt = ADAM(learning_rate)

My Flux is up to date, and there are no missing packages when I check with status. I’m getting the following error. How should I handle it?

ERROR: UndefVarError: `ADAM` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Hint: a global variable of this name may be made accessible by importing Optimisers in the current active module Main
Stacktrace:
 [1] top-level scope
   @ f:\file\Machine Learning\NeuralPDE.jl-master\ANN_study\study_ANN.jl:41

The answer was given in the message above:

ok!thank you.