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

**URL:** <https://discourse.julialang.org/t/flux-jl-methoderror-no-method-matching-loss/63478>\
**Category:** Machine Learning\
**Tags:** question, flux\
**Created:** [June 24, 2021, 2:43am UTC](https://discourse.julialang.org/t/flux-jl-methoderror-no-method-matching-loss/63478 "2021-06-24T02:43:54Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![rakeshvar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rakeshvar/32/3613_2.png) [@rakeshvar](https://discourse.julialang.org/u/rakeshvar)\
**Post date:** [June 24, 2021, 6:47am UTC](https://discourse.julialang.org/t/flux-jl-methoderror-no-method-matching-loss/63478/3 "2021-06-24T06:47:31Z")

</div>

```julia
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)`

---

_[View the full topic](https://discourse.julialang.org/t/flux-jl-methoderror-no-method-matching-loss/63478)._
