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

johnp
Hi Brian, Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
New
GilWright
Working through the steps (checking that the Info,plist matches exactly), run the demo game and what appears is grey but does not fill th...
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
conradwt
First, the code resources: Page 237: rumbl_umbrella/apps/rumbl/mix.exs Note: That this file is missing. Page 238: rumbl_umbrella/app...
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
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
s2k
Hi all, currently I wonder how the Tailwind colours work (or don’t work). For example, in app/views/layouts/application.html.erb I have...
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
dtonhofer
@parrt In the context of Chapter 4.3, the grammar Java.g4, meant to parse Java 6 compilation units, no longer passes ANTLR (currently 4....
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
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
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
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
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
AstonJ
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
New

Sub Categories: