# What wrong ? ERROR: UndefVarError: Gray not defined

**URL:** https://discourse.julialang.org/t/what-wrong-error-undefvarerror-gray-not-defined/69503
**Category:** General Usage
**Created:** [October 10, 2021, 8:06am UTC](https://discourse.julialang.org/t/what-wrong-error-undefvarerror-gray-not-defined/69503 "2021-10-10T08:06:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)
#### Post date: [October 10, 2021, 8:06am UTC](https://discourse.julialang.org/t/what-wrong-error-undefvarerror-gray-not-defined/69503/1 "2021-10-10T08:06:20Z")

</div>

```julia
julia> imagestrip(image::Matrix{<:Gray}) = Float32.(reshape(image, :))
ERROR: UndefVarError: Gray not defined
Stacktrace:
 [1] top-level scope
   @ REPL[43]:1

```

All code :[Recognize Handwriting Using an Artificial Neural Network | by Erik Engheim | Better Programming](https://betterprogramming.pub/handwriting-recognition-using-an-artificial-neural-network-78060d2a7963)  
Paul

---

<div class="post-metadata">

### Author: ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)
#### Post date: [October 10, 2021, 8:33am UTC](https://discourse.julialang.org/t/what-wrong-error-undefvarerror-gray-not-defined/69503/2 "2021-10-10T08:33:12Z")

</div>

It is missing the type `Gray` which the `Plots.jl` package will export for you. I see that `using Plots` is ran later in the tutorial so it is likely that the author just missed that it needed to be imported early and wanted to make it more pedagogical by importing it later when they did plotting.

But if you add a `using Plots` with the other `using` statements before the presented line, it should hopefully work fine.

EDIT:  
I found that `Flux.Data.MNIST` also contains a `const Gray = Colors.Gray{Colors.N0f8}`. This is probably the one that should be used, not sure why it seems like it was exported in the tuturial but not now. You can import it by

```julia
using Flux.Data.MNIST: Gray
# As before
using Flux, Flux.Data.MNIST, Statistics
using Flux: onehotbatch, onecold, crossentropy, throttle
using Base.Iterators: repeated
...

```
