iprog4u
Machine Learning in Elixir: Chapter 6 Axon.Display.as_table does not work (Page 133)
Please guide me in the right direction. I am able to get .as_graph() to display the model correctly
Axon.Display.as_graph(model, template)
however when I try to run .as_table() I get an error (CAUTION: wall of error text follows):
Axon.Display.as_table(model, template)
|> IO.puts
** (FunctionClauseError) no function clause matching in Axon.Display.do_axon_to_rows/6
The following arguments were given to Axon.Display.do_axon_to_rows/6:
# 1
%Axon.Node{
id: 5,
name: #Function<194.57606554/2 in Axon.name/2>,
mode: :both,
parent: [4],
parameters: [],
args: [:layer],
op: :softmax,
policy: #Axon.MixedPrecision.Policy<>,
hooks: [],
opts: [],
global_options: [],
op_name: :softmax,
meta: %{},
stacktrace: [
{Axon, :layer, 3, [file: ~c"lib/axon.ex", line: 346]},
{:elixir, :eval_external_handler, 3, [file: ~c"src/elixir.erl", line: 388]},
{:erl_eval, :do_apply, 7, [file: ~c"erl_eval.erl", line: 919]},
{:erl_eval, :expr, 6, [file: ~c"erl_eval.erl", line: 663]},
{:elixir, :eval_forms, 4, [file: ~c"src/elixir.erl", line: 366]},
{Module.ParallelChecker, :verify, 1, [file: ~c"lib/module/parallel_checker.ex", line: 120]}
]
}
# 2
%{
1 => %Axon.Node{
id: 1,
name: #Function<195.57606554/2 in Axon.name/2>,
mode: :both,
parent: [],
parameters: [],
args: [],
op: :input,
policy: #Axon.MixedPrecision.Policy<>,
hooks: [],
opts: [shape: {nil, 748}, optional: false],
global_options: [],
op_name: :input,
meta: nil,
stacktrace: [
{Axon, :layer, 3, [file: ~c"lib/axon.ex", line: 346]},
{:elixir, :eval_external_handler, 3, [file: ~c"src/elixir.erl", line: 388]},
{:erl_eval, :do_apply, 7, [file: ~c"erl_eval.erl", line: 919]},
{:erl_eval, :expr_list, 7, [file: ~c"erl_eval.erl", line: 1207]},
{:erl_eval, :expr, 6, [file: ~c"erl_eval.erl", line: 625]},
{:erl_eval, :expr_list, 7, [file: ~c"erl_eval.erl", line: 1207]}
]
},
2 => %Axon.Node{
id: 2,
name: #Function<194.57606554/2 in Axon.name/2>,
mode: :both,
parent: [1],
parameters: [
%Axon.Parameter{
name: "kernel",
template: #Function<485.57606554/1 in Axon.shape_fun/2>,
shape: nil,
initializer: #Function<3.47872556/3 in Axon.Initializers.glorot_uniform/1>,
children: nil,
type: {:f, 32},
frozen: false,
kind: :parameter
},
%Axon.Parameter{
name: "bias",
template: #Function<485.57606554/1 in Axon.shape_fun/2>,
shape: nil,
initializer: #Function<23.47872556/2 in Axon.Initializers.zeros/0>,
children: nil,
type: {:f, 32},
frozen: false,
kind: :parameter
}
],
args: [:layer, :parameter, :parameter],
op: :dense,
policy: #Axon.MixedPrecision.Policy<>,
hooks: [],
opts: [],
global_options: [],
op_name: :dense,
meta: %{use_bias: true, units: 128},
stacktrace: [
{Axon, :layer, 3, [file: ~c"lib/axon.ex", line: 346]},
{Axon, :dense, 3, [file: ~c"lib/axon.ex", line: 877]},
{:elixir, :eval_external_handler, 3, [file: ~c"src/elixir.erl", line: 388]},
{:erl_eval, :do_apply, 7, [file: ~c"erl_eval.erl", line: 919]},
{:erl_eval, :expr_list, 7, [file: ~c"erl_eval.erl", line: 1207]},
{:erl_eval, :expr, 6, [file: ~c"erl_eval.erl", line: 625]}
]
},
3 => %Axon.Node{
id: 3,
name: #Function<194.57606554/2 in Axon.name/2>,
mode: :both,
parent: [2],
parameters: [],
args: [:layer],
op: :relu,
policy: #Axon.MixedPrecision.Policy<>,
hooks: [],
opts: [],
global_options: [],
op_name: :relu,
meta: %{},
stacktrace: [
{Axon, :layer, 3, [file: ~c"lib/axon.ex", line: 346]},
{:elixir, :eval_external_handler, 3, [file: ~c"src/elixir.erl", line: 388]},
{:erl_eval, :do_apply, 7, [file: ~c"erl_eval.erl", line: 919]},
{:erl_eval, :expr_list, 7, [file: ~c"erl_eval.erl", line: 1207]},
{:erl_eval, :expr, 6, [file: ~c"erl_eval.erl", line: 625]},
{:erl_eval, :expr, 6, [file: ~c"erl_eval.erl", line: 663]}
]
},
4 => %Axon.Node{
id: 4,
name: #Function<194.57606554/2 in Axon.name/2>,
mode: :both,
parent: [3],
parameters: [
%Axon.Parameter{
name: "kernel",
template: #Function<485.57606554/1 in Axon.shape_fun/2>,
shape: nil,
initializer: #Function<3.47872556/3 in Axon.Initializers.glorot_uniform/1>,
children: nil,
type: {:f, 32},
frozen: false,
kind: :parameter
},
%Axon.Parameter{
name: "bias",
template: #Function<485.57606554/1 in Axon.shape_fun/2>,
shape: nil,
initializer: #Function<23.47872556/2 in Axon.Initializers.zeros/0>,
children: nil,
type: {:f, 32},
frozen: false,
kind: :parameter
}
],
args: [:layer, :parameter, :parameter],
op: :dense,
policy: #Axon.MixedPrecision.Policy<>,
hooks: [],
opts: [],
global_options: [],
op_name: :dense,
meta: %{use_bias: true, units: 10},
stacktrace: [
{Axon, :layer, 3, [file: ~c"lib/axon.ex", line: 346]},
{Axon, :dense, 3, [file: ~c"lib/axon.ex", line: 877]},
{:elixir, :eval_external_handler, 3, [file: ~c"src/elixir.erl", line: 388]},
{:erl_eval, :do_apply, 7, [file: ~c"erl_eval.erl", line: 919]},
{:erl_eval, :expr, 6, [file: ~c"erl_eval.erl", line: 663]},
{:elixir, :eval_forms, 4, [file: ~c"src/elixir.erl", line: 366]}
]
},
5 => %Axon.Node{
id: 5,
name: #Function<194.57606554/2 in Axon.name/2>,
mode: :both,
parent: [4],
parameters: [],
args: [:layer],
op: :softmax,
policy: #Axon.MixedPrecision.Policy<>,
hooks: [],
opts: [],
global_options: [],
op_name: :softmax,
meta: %{},
stacktrace: [
{Axon, :layer, 3, [file: ~c"lib/axon.ex", line: 346]},
{:elixir, :eval_external_handler, 3, [file: ~c"src/elixir.erl", line: 388]},
{:erl_eval, :do_apply, 7, [file: ~c"erl_eval.erl", line: 919]},
{:erl_eval, :expr, 6, [file: ~c"erl_eval.erl", line: 663]},
{:elixir, :eval_forms, 4, [file: ~c"src/elixir.erl", line: 366]},
{Module.ParallelChecker, :verify, 1, [file: ~c"lib/module/parallel_checker.ex", line: 120]}
]
}
}
# 3
#Nx.Tensor<
f32[1][784]
Nx.TemplateBackend
>
# 4
%{}
# 5
%{}
# 6
%{num_params: 0, total_param_byte_size: 0}
Attempted function clauses (showing 2 out of 2):
defp do_axon_to_rows(%Axon.Node{id: id, op: structure, op_name: :container, parent: [parents], name: name_fn}, nodes, templates, cache, op_counts, model_info)
defp do_axon_to_rows(%Axon.Node{
id: id,
parent: parents,
parameters: params,
name: name_fn,
opts: opts,
policy: %{params: {_, bitsize}},
op_name: op_name
}, nodes, templates, cache, op_counts, model_info)
(axon 0.7.0) lib/axon/display.ex:93: Axon.Display.do_axon_to_rows/6
(axon 0.7.0) lib/axon/display.ex:85: Axon.Display.axon_to_rows/6
(axon 0.7.0) lib/axon/display.ex:39: Axon.Display.as_table/2
#cell:r744jk7wwgcawf6v:2: (file)
Perhaps not hyper important as the graph contains the same info but it is nice how the table has the labels.
Marked As Solved
iprog4u
Removing specific versions or updating to the latest available version corrected the issue for me. Pol Valente was kind enough to update the Axon lib, thanks Pol!
Mix.install([
:axon,
:nx,
:exla,
:kino,
:table_rex,
:scidata
])
Nx.default_backend(EXLA.Backend)
…
…
…
Axon.Display.as_table(model, template)
|> IO.puts()
+------------------------------------------------------------------------------------------------------------------+
| Model |
+=======================+===============================+==============+===================+=======================+
| Layer | Input Shape | Output Shape | Options | Parameters |
+=======================+===============================+==============+===================+=======================+
| images ( input ) | %{} | f32[1][784] | shape: {nil, 784} | |
| | | | optional: false | |
+-----------------------+-------------------------------+--------------+-------------------+-----------------------+
| dense_0 ( dense ) | %{"images" => "f32[1][784]"} | f32[1][128] | | kernel: f32[784][128] |
| | | | | bias: f32[128] |
+-----------------------+-------------------------------+--------------+-------------------+-----------------------+
| relu_0 ( relu ) | %{"dense_0" => "f32[1][128]"} | f32[1][128] | | |
+-----------------------+-------------------------------+--------------+-------------------+-----------------------+
| dense_1 ( dense ) | %{"relu_0" => "f32[1][128]"} | f32[1][10] | | kernel: f32[128][10] |
| | | | | bias: f32[10] |
+-----------------------+-------------------------------+--------------+-------------------+-----------------------+
| softmax_0 ( softmax ) | %{"dense_1" => "f32[1][10]"} | f32[1][10] | | |
+-----------------------+-------------------------------+--------------+-------------------+-----------------------+
Total Parameters: 101770
Total Parameters Memory: 407.08 kilobytes
Popular Pragmatic Bookshelf topics
Hello Brian,
I have some problems with running the code in your book. I like the style of the book very much and I have learnt a lot as...
New
Title: Web Development with Clojure, Third Edition, pg 116
Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
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
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
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
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
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113.
Iteration A1 - Seeing the list of prod...
New
The allprojects block listed on page 245 produces the following error when syncing gradle:
“org.gradle.api.GradleScriptException: A prob...
New
AWDWR 7, page 152, page 153:
Hello everyone,
I’m a little bit lost on the hotwire part. I didn’t fully understand it.
On page 152 @rub...
New
I’ve got to the end of Ch. 11, and the app runs, with all tabs displaying what they should – at first. After switching around between St...
New
Other popular topics
Reading something? Working on something? Planning something? Changing jobs even!?
If you’re up for sharing, please let us know what you’...
New
Learn from the award-winning programming series that inspired the Elixir language, and go on a step-by-step journey through the most impo...
New
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor?
Also, I want to know if someone is using it for program...
New
This looks like a stunning keycap set :orange_heart:
A LEGENDARY KEYBOARD LIVES ON
When you bought an Apple Macintosh computer in the e...
New
The V Programming Language
Simple language for building maintainable programs
V is already mentioned couple of times in the forum, but I...
New
Author Spotlight
Jamis Buck
@jamis
This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
Jan | Rethink the Computer.
Jan turns your computer into an AI machine by running LLMs locally on your computer. It’s a privacy-focus, l...
New
Get the comprehensive, insider information you need for Rails 8 with the new edition of this award-winning classic.
Sam Ruby @rubys
...
New
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
Background
Lately I am in a quest to find a good quality TTS ai generation tool to run locally in order to create audio for some videos I...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /python
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /emacs
- /haskell
- /svelte
- /onivim
- /typescript
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /flutter
- /vscode
- /ash
- /html
- /opensuse
- /deepseek
- /zig
- /centos
- /php
- /scala
- /react-native
- /lisp
- /textmate
- /sublime-text
- /nixos
- /debian
- /agda
- /django
- /deno
- /kubuntu
- /arch-linux
- /nodejs
- /ubuntu
- /spring
- /revery
- /manjaro
- /lua
- /julia
- /diversity
- /markdown
- /quarkus









