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

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
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
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
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
dsmith42
Hey there, I’m enjoying this book and have learned a few things alredayd. However, in Chapter 4 I believe we are meant to see the “>...
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
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
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

Other popular topics Top

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
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
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
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
AstonJ
Biggest jackpot ever apparently! :upside_down_face: I don’t (usually) gamble/play the lottery, but working on a program to predict the...
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
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
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New

Sub Categories: