iprog4u

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.

First Post!

iprog4u

iprog4u

Updating to latest versions does not correct the error.

Mix.install([
  {:axon, "~> 0.7.0"},
  {:nx, "~> 0.9.2"},
  {:exla, "~> 0.9.2"},
  {:stb_image, "~> 0.6.10"},
  {:kino, "~> 0.17.0"},
  {:table_rex, "~> 3.1.1"}
])

Anyone have any ideas what else to try?

Where Next?

Popular Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
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
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
New
cro
I am working on the “Your Turn” for chapter one and building out the restart button talked about on page 27. It recommends looking into ...
New
hgkjshegfskef
The test is as follows: Scenario: Intersecting a scaled sphere with a ray Given r ← ray(point(0, 0, -5), vector(0, 0, 1)) And s ← sphere...
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
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
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
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New
dachristenson
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 Top

PragmaticBookshelf
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
AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
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
Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New

Sub Categories: