simple example returns MethodError: no method matching Dense(::Pair{Int64, Int64})

161 Views Asked by At

I am running through basic examples for Flux, and I am getting MethodErrors when running code verbatim through the REPL. I am using a fresh REPL and am on VERSION 1.8.2 for linux.

julia> using Flux

julia> actual(x) = 4x + 2

actual (generic function with 1 method)

julia> x_train, x_test = hcat(0:5...), hcat(6:10...)

([0 1 … 4 5], [6 7 … 9 10])

julia> y_train, y_test = actual.(x_train), actual.(x_test)

([2 6 … 18 22], [26 30 … 38 42])

julia> model = Dense(1 => 1)

ERROR: MethodError: no method matching Dense(::Pair{Int64, Int64})

Closest candidates are:

  Dense(::Any, ::Any) at ~/.julia/packages/Flux/qXNjB/src/layers/basic.jl:88

  Dense(::S, ::T, ::F) where {F, S, T} at ~/.julia/packages/Flux/qXNjB/src/layers/basic.jl:83

  Dense(::Integer, ::Integer) at ~/.julia/packages/Flux/qXNjB/src/layers/basic.jl:90

  ...

Stacktrace:

 [1] top-level scope

   @ REPL[5]:1


I got a similar error when using gradient from another example

I was expecting the REPL to return

0

There are 0 best solutions below