juliaflux-machine-learning

Julia ERROR: UndefVarError: σ not defined


I am running this from julia:

W1 = param(rand(3, 5))
b1 = param(rand(3))
layer1(x) = W1 * x .+ b1
W2 = param(rand(2, 3))
b2 = param(rand(2))

layer2(x) = W2 * x .+ b2
model(x) = layer2(σ.(layer1(x)))

model(rand(5))

I am getting this error:

ERROR: UndefVarError: σ not defined
Stacktrace:
[1] model(::Array{Float64,1}) at ./REPL[35]:1

I dont understand the error. I am new to julia. Please help me out here. I am following this tutorial: https://fluxml.github.io/Flux.jl/stable/models/basics.html#Taking-Gradients-1

Thank you.


Solution

  • One can check the comments. This can be solved by adding using Flux or using Foo:bar, baz before the the given code.