Machine Learning in Elixir: Chapter 10/11 Code fixes that worked for me (Page 226-260)

Page 226
Mix install uses older versins of exla, should 0.6 to work with cuda120

Page 230
targets pipeline in Data module misses |> Nx.tensor()

Page 231
chunk_every misses :discard?

Page 232
uses non existing variable prices
Also windows_size in code is 30, text says 5

Page 234
Model seems off, I get an error about empty tensor resulting from conv.
This worked for me but doesn’t match the image of the model

cnn_model =
Axon.input("stock_price")
|> Axon.nx(&Nx.new_axis(&1, -1))
|> Axon.conv(32, kernel_size: {window_size, 1}, activation: :relu)
|> Axon.dense(32, activation: :relu)
|> Axon.dense(1)
template = Nx.template({32, 10, 1}, :f32)
Axon.Display.as_graph(cnn_model, template)

Page 236
Eval form is cut of in pdf

Chapter 11
Page 257

With current bumblebee version should be

{:ok, generation_config} = Bumblebee.load_generation_config({:hf, "microsoft/DialoGPT-medium"})

serving =
  Bumblebee.Text.conversation(model, tokenizer,
   generation_config,
   compile: [batch_size: 1, sequence_length: 1000],
   defn_options: [compiler: EXLA]
  )

Page 260
should be image instead of image.data

2 Likes

Thanks for pointing these out! I’ve addressed them