baskint

baskint

Machine Learning in Elixir:294 Axon.Loop.log/4 is undefined or private. Did you mean: * log/2 * log/3

@seanmor5

On Page 294, cannot run the training loop. I think the Axon.Loop.handle signature has changed. Getting this error:

step_fn
|> Axon.Loop.loop(init_fn)
|> Axon.Loop.handle(:epoch_completed, &GAN.display_sample(&1, generator_fn))
|> Axon.Loop.log(:iteration_completed, fn
%Axon.Loop.State{epoch: epoch, iteration: iter, step_state: state} ->
d_loss = state[:loss]["discriminator"]
g_loss = state[:loss]["generator"]
"\rEpoch: #{epoch}, batch: #{iter},"
<> " d_loss: #{Nx.to_number(d_loss)},"
<> " g_loss: #{Nx.to_number(g_loss)}"
end, :stdio)
|> Axon.Loop.run(train_data, %{}, compiler: EXLA, epochs: 10)

and even changed to this:
Axon.Loop.handle_event(:epoch_completed, &GAN.display_sample(&1, generator_fn))

Here is the error I am seeing:

** (UndefinedFunctionError) function Axon.Loop.log/4 is undefined or private. Did you mean:

      * log/2
      * log/3

    (axon 0.6.0) Axon.Loop.log(#Axon.Loop<metrics: %{}, handlers: %{started: [], halted: [], completed: [], epoch_started: [], iteration_started: [], iteration_completed: [], epoch_completed: [{#Function<42.105768164/1 in :erl_eval.expr/6>, #Function<6.115020529/2 in Axon.Loop.build_filter_fn/1>}], epoch_halted: []}, ...>, :iteration_completed, #Function<42.105768164/1 in :erl_eval.expr/6>, :stdio)
    #cell:yoevooqxcl5jdmoy:12: (file)

Marked As Solved

seanmor5

seanmor5

Author of Genetic Algorithms in Elixir

Thanks for pointing out. The correct function is:

|> Axon.Loop.log(fn
  %Axon.Loop.State{epoch: epoch, iteration: iter, step_state: state} ->
    d_loss = state[:loss]["discriminator"]
    g_loss = state[:loss]["generator"]
    "\rEpoch: #{epoch}, batch: #{iter},"
      <> " d_loss: #{Nx.to_number(d_loss)},"
      <> " g_loss: #{Nx.to_number(g_loss)}"
end, event: :iteration_completed, device: :stdio)

Where Next?

Popular Pragmatic Bookshelf topics Top

jeffmcompsci
Title: Design and Build Great Web APIs - typo “https://company-atk.herokuapp.com/2258ie4t68jv” (page 19, third bullet in URL list) Typo:...
New
Alexandr
Hi everyone! There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New
swlaschin
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
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
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
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
New
taguniversalmachine
Hi, I am getting an error I cannot figure out on my test. I have what I think is the exact code from the book, other than I changed “us...
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New

Other popular topics Top

AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
AstonJ
Thanks to @foxtrottwist’s and @Tomas’s posts in this thread: Poll: Which code editor do you use? I bought Onivim! :nerd_face: https://on...
New
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
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
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New

Sub Categories: