FLUX.JL -- MethodError: no method matching loss()

MethodError: no method matching loss(::NamedTuple{(:images, :labels), 
                              Tuple{Vector{Matrix{Gray{Float64}}}, 
                              Vector{Flux.OneHotArray{UInt32, 2, 0, 1, UInt32}}}})
Closest candidates are:
  loss(::Any, ::Any) at In[19]:2

Since the error says that it is trying to call loss on a (named)tuple, I would just change the definition of loss function from
loss(x, y) = Flux.Losses.logitcrossentropy(model(x), y)
to
loss((x, y)) = Flux.Losses.logitcrossentropy(model(x), y)

1 Like