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

iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
raul
Page 28: It implements io.ReaderAt on the store type. Sorry if it’s a dumb question but was the io.ReaderAt supposed to be io.ReadAt? ...
New
adamwoolhether
When trying to generate the protobuf .go file, I receive this error: Unknown flag: --go_opt libprotoc 3.12.3 MacOS 11.3.1 Googling ...
New
curtosis
Running mix deps.get in the sensor_hub directory fails with the following error: ** (Mix) No SSH public keys found in ~/.ssh. An ssh aut...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New
dachristenson
I’ve got to the end of Ch. 11, and the app runs, with all tabs displaying what they should – at first. After switching around between St...
New

Other popular topics Top

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
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
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
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
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
New
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New

Sub Categories: