sabiwara

sabiwara

Machine Learning in Elixir: Chapter 13 code errors

Hello @seanmor5! Thanks a lot for the amazing book and new chapter :purple_heart:

I got a couple of errors when trying to run the examples in Chap. 13 and they don’t seem to have been reported yet:

  1. p.313 The :sequence_length and :batch_size keys of text_embedding had to be popped and nested in a :compile key:
opts = Keyword.validate!(opts, [
  :defn_options, sequence_length: 64, batch_size: 16 ])

{model_info, tokenizer} = load()
Bumblebee.Text.TextEmbedding.text_embedding(model_info, tokenizer, opts)
  1. p.316 predict/1 returns an %{embedding: Nx.Tensor.t()}, should return a Nx.Tensor.t() to work when adding it to the changeset later:
def predict(text) do
-  Nx.Serving.batched_run(BookSearchModel, text)
+  Nx.Serving.batched_run(BookSearchModel, text).embedding
end
  1. p.320 needs to assign :query
def mount(_params, _session, socket) do
-  {:ok, assign(socket, :results, [])}
+  {:ok, assign(socket, results: [], query: nil)}
end
  1. p.321 Typo in HTML template
<a
-  href{~p"/book/#{result.id}"}
+  href={~p"/book/#{result.id}"}

Most Liked

sabiwara

sabiwara

@pieteeken I changed it as follows, fixed it for me:

    opts = Keyword.validate!(opts, [:defn_options, sequence_length: 64, batch_size: 16])
    {defn_opts, compile_opts} = Keyword.pop!(opts, :defn_options)
    opts = [defn_options: defn_opts, compile: compile_opts]
pieteeken

pieteeken

OK. It’s working.
And I also got the results. But that was because of one forgotten change from the book.

Popular Pragmatic Bookshelf topics Top

jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New
edruder
I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here. ...
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
adamwoolhether
When trying to generate the protobuf .go file, I receive this error: Unknown flag: --go_opt libprotoc 3.12.3 MacOS 11.3.1 Googling ...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
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
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
New

Other popular topics Top

Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
New
AstonJ
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
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
New
CommunityNews
A Brief Review of the Minisforum V3 AMD Tablet. Update: I have created an awesome-minisforum-v3 GitHub repository to list information fo...
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: