pieteeken

pieteeken

Machine Learning in Elixir: Comments on Chapter 12, Version B 3.0

Comments on Chapter 12, Version B 3.0

@seanmor5

All the Axon.Optimizers.adam(…) should be replaced by Polaris.Optimizers.adam( learning_rate: …)

Section Learning a Structured Latent

line 31: epsilon = Nx.random_normal(noise_shape) should be replaced by:

key = Nx.Random.key(42)
{epsilon, new_key} = Nx.Random.normal(key, shape: noise_shape)

line 98: decoder_params = decoder_init_fn.(Nx.random_uniform({64, 2}), init_state)
should be replaced by:

key = Nx.Random.key(100)
{decoder_params, _new_key} = decoder_init_fn.(Nx.Random.uniform(key, shape: {64, 2}),init_state)

In the last cell of this section there is an Error.
Line 10: |> Axon.Loop.run(train_data, %{}, compiler: EXLA, epochs: 10)
Don’t know how to handle it.

** (ArithmeticError) bad argument in arithmetic expression: {2} * 1
    :erlang.*({2}, 1)
    (elixir 1.15.7) lib/tuple.ex:167: Tuple.product/2
    (elixir 1.15.7) lib/tuple.ex:167: Tuple.product/2
    (axon 0.6.1) lib/axon/initializers.ex:603: Axon.Initializers.compute_fans/1
    (axon 0.6.1) lib/axon/initializers.ex:578: Axon.Initializers."__defn:variance_scaling_impl__"/3
    (axon 0.6.1) lib/axon/compiler.ex:1092: Axon.Compiler.init_param/6
    (elixir 1.15.7) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
    #cell:k4cy577ik7plpwyh:10: (file)

Section Generating with GANs

line 39: g_params = generator_init_fn.(Nx.random_normal({64, 128}), init_state)
should be replaced by:

key = Nx.Random.key(42)
g_params = generator_init_fn.(Nx.Random.normal(key, shape: {64, 128}), init_state)

line 58 +70: latent = Nx.random_normal({batch_size, 128})
should be replaced by:

key = Nx.Random.key(100)
latent = Nx.Random.normal(key, shape: {batch_size, 128})    

line 143: latent = Nx.random_normal({3, 128})
should be replaced by:

key = Nx.Random.key(42)
latent = Nx.Random.normal(key, shape: {3, 128})

Then the last cell.
There is a warning: Axon.Loop.handle/3 is deprecated. handle/4 is deprecated, use handle_event/4 instead.
That line is: |> Axon.Loop.handle(:epoch_completed, &GAN.display_sample(&1, generator_fn))
It should be:

|> Axon.Loop.handle_event(:epoch_completed, &GAN.display_sample(&1, generator_fn))

There is also an error I don’t know to solve. The same as in the section before
Line ten of the last cell: |> Axon.Loop.run(train_data, %{}, compiler: EXLA, epochs: 10)

15:46:28.070 [debug] Forwarding options: [compiler: EXLA] to JIT compiler
** (ArithmeticError) bad argument in arithmetic expression: {2} * 1
    :erlang.*({2}, 1)
    (elixir 1.15.7) lib/tuple.ex:167: Tuple.product/2
    (elixir 1.15.7) lib/tuple.ex:167: Tuple.product/2
    (axon 0.6.1) lib/axon/initializers.ex:603: Axon.Initializers.compute_fans/1
    (axon 0.6.1) lib/axon/initializers.ex:578: Axon.Initializers."__defn:variance_scaling_impl__"/3
    (axon 0.6.1) lib/axon/compiler.ex:1092: Axon.Compiler.init_param/6
    (elixir 1.15.7) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
    #cell:3qkqd37egg5g6jsz:10: (file)

Where Next?

Popular Pragmatic Bookshelf topics Top

telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
herminiotorres
Hi @Margaret , On page VII the book tells us the example and snippets will be all using Elixir version 1.11 But on page 3 almost the en...
New
cro
I am working on the “Your Turn” for chapter one and building out the restart button talked about on page 27. It recommends looking into ...
New
rmurray10127
Title: Intuitive Python: docker run… denied error (page 2) Attempted to run the docker command in both CLI and Powershell PS C:\Users\r...
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
leonW
I ran this command after installing the sample application: $ cards add do something --owner Brian And got a file not found error: Fil...
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
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
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
tkhobbes
After some hassle, I was able to finally run bin/setup, now I have started the rails server but I get this error message right when I vis...
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
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
axelson
I’ve been really enjoying obsidian.md: It is very snappy (even though it is based on Electron). I love that it is all local by defaul...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New

Sub Categories: