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"]
  ...

Popular Prag Prog topics Top

iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
New
gilesdotcodes
In case this helps anyone, I’ve had issues setting up the rails source code. Here were the solutions: In Gemfile, change gem 'rails' t...
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
New
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New

Latest in PragProg

View all threads ❯