Skip to content

Handle Model Display Correctly #605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025
Merged

Conversation

heywhy
Copy link
Contributor

@heywhy heywhy commented Jan 5, 2025

Fixes #604 and multi inputs model, see example below:

[Axon.input("input_1"), Axon.input("input_2")]
|> Axon.concatenate()
|> Axon.dense(32, activation: :relu)
|> Axon.dropout(rate: 0.5)
|> Axon.dense(1)
|> Axon.Display.as_table(%{"input_1" => Nx.iota({2, 1}), "input_2" => Nx.iota({2, 2})})

Expected output

+------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                  Model                                                                   |
+===============================+============================================+======================+=================+====================+
| Layer                         | Input Shape                                | Output Shape         | Options         | Parameters         |
+===============================+============================================+======================+=================+====================+
| input_1 ( input )             | %{}                                        | s32[2][1]            | shape: nil      |                    |
|                               |                                            |                      | optional: false |                    |
+-------------------------------+--------------------------------------------+----------------------+-----------------+--------------------+
| input_2 ( input )             | %{}                                        | s32[2][2]            | shape: nil      |                    |
|                               |                                            |                      | optional: false |                    |
+-------------------------------+--------------------------------------------+----------------------+-----------------+--------------------+
| container_0 ( container )     | {}                                         | s32[2][1], s32[2][2] |                 |                    |
+-------------------------------+--------------------------------------------+----------------------+-----------------+--------------------+
| concatenate_0 ( concatenate ) | %{"container_0" => "s32[2][1], s32[2][2]"} | s32[2][3]            | axis: -1        |                    |
+-------------------------------+--------------------------------------------+----------------------+-----------------+--------------------+
| dense_0 ( dense )             | %{"concatenate_0" => "s32[2][3]"}          | f32[2][32]           |                 | kernel: f32[3][32] |
|                               |                                            |                      |                 | bias: f32[32]      |
+-------------------------------+--------------------------------------------+----------------------+-----------------+--------------------+
| relu_0 ( relu )               | %{"dense_0" => "f32[2][32]"}               | f32[2][32]           |                 |                    |
+-------------------------------+--------------------------------------------+----------------------+-----------------+--------------------+
| dropout_0 ( dropout )         | %{"relu_0" => "f32[2][32]"}                | f32[2][32]           | rate: 0.5       | key: f32[2]        |
+-------------------------------+--------------------------------------------+----------------------+-----------------+--------------------+
| dense_1 ( dense )             | %{"dropout_0" => "f32[2][32]"}             | f32[2][1]            |                 | kernel: f32[32][1] |
|                               |                                            |                      |                 | bias: f32[1]       |
+-------------------------------+--------------------------------------------+----------------------+-----------------+--------------------+

@seanmor5 seanmor5 merged commit 15ace5c into elixir-nx:main Apr 22, 2025
4 of 5 checks passed
@heywhy heywhy deleted the fix-display branch April 23, 2025 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display.as_table/2 example failing
2 participants