# Tanmay Bakshi tried to teach me ML, but I failed and I don't know why

**URL:** <https://discourse.julialang.org/t/tanmay-bakshi-tried-to-teach-me-ml-but-i-failed-and-i-dont-know-why/37415>\
**Category:** Machine Learning\
**Created:** [April 11, 2020, 8:28pm UTC](https://discourse.julialang.org/t/tanmay-bakshi-tried-to-teach-me-ml-but-i-failed-and-i-dont-know-why/37415 "2020-04-11T20:28:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Klaus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaus/32/13623_2.png) [@Klaus](https://discourse.julialang.org/u/Klaus)\
**Post date:** [April 11, 2020, 8:28pm UTC](https://discourse.julialang.org/t/tanmay-bakshi-tried-to-teach-me-ml-but-i-failed-and-i-dont-know-why/37415/1 "2020-04-11T20:28:18Z")

</div>

I tried this code snippet from the book (…springboard to machine learning for all ages):

```julia
using Metalhead: VGG19, preprocess, load, labels
using Flux: onecold

model = VGG19()
class_labels = labels(model)

print("Enter the name of your file: ")
user_image = preprocess(load(readline()))
model_prediction = model(user_image)
top_class = onecold(model_prediction)[1]
class_name = labels[top_class]

println("I think this is $(class_name)")

```

But then I got this error message:

```julia
julia> include("test09.jl")
Enter the name of your file: mouse.jpg
ERROR: LoadError: MethodError: no method matching getindex(::typeof(labels), ::Int64)
Stacktrace:
 [1] top-level scope at C:\julia\julia-1.3.1\examples\test09.jl:11
 [2] include at .\boot.jl:328 [inlined]
 [3] include_relative(::Module, ::String) at .\loading.jl:1105
 [4] include(::Module, ::String) at .\Base.jl:31
 [5] include(::String) at .\client.jl:424
 [6] top-level scope at none:0
in expression starting at C:\julia\julia-1.3.1\examples\test09.jl:11

```

Unfortunately I could not resolve this issue.

It would be great, if someone could give me some help on this problem. I really got stuck.

Thank you!  
Klaus

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [April 11, 2020, 11:47pm UTC](https://discourse.julialang.org/t/tanmay-bakshi-tried-to-teach-me-ml-but-i-failed-and-i-dont-know-why/37415/2 "2020-04-11T23:47:05Z")

</div>

That error message is hard to interpret for someone new to the language. What it means is that you tried to index a function like an array. The error occurs here:

```julia
class_name = labels[top_class]

```

Note that `labels` is actually a function, not an array. That line is probably supposed to be this:

```julia
class_name = class_labels[top_class]

```

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [April 12, 2020, 12:07am UTC](https://discourse.julialang.org/t/tanmay-bakshi-tried-to-teach-me-ml-but-i-failed-and-i-dont-know-why/37415/3 "2020-04-12T00:07:02Z")

</div>

I opened up an issue on github to see if it’s possible to print a more readable error message for this kind of situation.

[https://github.com/JuliaLang/julia/issues/35439](https://github.com/JuliaLang/julia/issues/35439)

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [April 12, 2020, 12:42am UTC](https://discourse.julialang.org/t/tanmay-bakshi-tried-to-teach-me-ml-but-i-failed-and-i-dont-know-why/37415/4 "2020-04-12T00:42:54Z")

</div>

> [@CameronBieganek](#):
>
> class\_name = labels[top\_class]

Just guessing, what if you tried `labels(top_class)`. I can’t runt he code cos I don’t have the mouse jpeg.

---

<div class="post-metadata">

**Author:** ![Klaus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaus/32/13623_2.png) [@Klaus](https://discourse.julialang.org/u/Klaus)\
**Post date:** [April 12, 2020, 1:39pm UTC](https://discourse.julialang.org/t/tanmay-bakshi-tried-to-teach-me-ml-but-i-failed-and-i-dont-know-why/37415/5 "2020-04-12T13:39:08Z")

</div>

WONDERFUL - you are a genius! You are a great reviewer of Julia-ML-books! Thanks a lot - with your help I can move forwards!

THANK YOU so much!

Dr. Nikolaus Albrecht
