glappen

glappen

Machine Learning in Elixir: Error running last example in Chapter 1 (Evaluating the Trained Model)

@seanmor5

I am enjoying the book so far, but ran into an Elixir error on the last example in chapter 1:

In my last Livebook cell I have:

data = [{x_test, y_test}]

model
|> Axon.Loop.evaluator()
|> Axon.Loop.metric(:accuracy)
|> Axon.Loop.run(data, trained_model_state)```

and I get this error:

** (ArgumentError) cannot broadcast tensor of dimensions {120} to {30}
(nx 0.7.2) lib/nx/shape.ex:345: Nx.Shape.binary_broadcast/4
(nx 0.7.2) lib/nx.ex:5427: Nx.devectorized_element_wise_pred_op/3
(axon 0.6.1) lib/axon/metrics.ex:88: Axon.Metrics.accuracy_transform/4
(axon 0.6.1) lib/axon/metrics.ex:467: anonymous fn/4 in Axon.Metrics.running_average/1
(axon 0.6.1) lib/axon/loop.ex:1974: anonymous fn/5 in Axon.Loop.build_batch_fn/2
(elixir 1.15.7) lib/enum.ex:3945: anonymous fn/4 in Enum.zip_with/3
(elixir 1.15.7) lib/enum.ex:4005: anonymous fn/3 in Enum.zip_reduce/4
#cell:vs5uswexiozx5vnr:6: (file)

I typed in all the examples verbatim up to that point. Any ideas what is going on here?

Thanks,

Greg

Most Liked

gtaranti

gtaranti

My bad!
The code runs correctly…

I’ve had written :

y_test =
  train_df["species"]
  ...

instead of

y_test =
  test_df["species"]
  ...

Where Next?

Popular Pragmatic Bookshelf topics Top

jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
fynn
This is as much a suggestion as a question, as a note for others. Locally the SGP30 wasn’t available, so I ordered a SGP40. On page 53, ...
New
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
nicoatridge
Hi, I have just acquired Michael Fazio’s “Kotlin and Android Development” to learn about game programming for Android. I have a game in p...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
Charles
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
mert
AWDWR 7, page 152, page 153: Hello everyone, I’m a little bit lost on the hotwire part. I didn’t fully understand it. On page 152 @rub...
New
jwandekoken
Book: Programming Phoenix LiveView, page 142 (157/378), file lib/pento_web/live/product_live/form_component.ex, in the function below: d...
New
New

Other popular topics Top

PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
New

Sub Categories: