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.

Where Next?

Popular Pragmatic Bookshelf topics Top

jimmykiang
This test is broken right out of the box… — FAIL: TestAgent (7.82s) agent_test.go:77: Error Trace: agent_test.go:77 agent_test.go:...
New
iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
JohnS
I can’t setup the Rails source code. This happens in a working directory containing multiple (postgres) Rails apps. With: ruby-3.0.0 s...
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
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
jskubick
I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New
brunogirin
When running tox for the first time, I got the following error: ERROR: InterpreterNotFound: python3.10 I realised that I was running ...
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
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
AstonJ
What chair do you have while working… and why? Is there a ‘best’ type of chair or working position for developers?
New
wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
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
PragmaticBookshelf
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
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: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
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: