Comments (5)
train_data = Scidata.MNIST.download()
test_data = Scidata.MNIST.download_test()
{train_data, train_labels} = train_data
{train_binary, train_type, train_shape} = train_data
{train_label_binary, train_label_type, train_label_shape} = train_labels
train_y =
Nx.from_binary(train_label_binary, train_label_type)
|> Nx.reshape(train_label_shape)
|> Nx.new_axis(-1)
|> Nx.equal(Enum.to_list(0..9) |> Nx.tensor())
|> Nx.to_batched(32)
|> Enum.to_list()
train_x =
Nx.from_binary(train_binary, train_type)
|> Nx.reshape(train_shape)
|> Nx.divide(255)
|> Nx.to_batched(32)
|> Enum.to_list()
data = Enum.zip(train_x, train_y)
training_count = floor(0.8 * Enum.count(data))
validation_count = floor(0.2 * training_count)
{training_data, test_data} = Enum.split(data, training_count)
{validation_data, training_data} = Enum.split(training_data, validation_count)
model =
Axon.input("input_0", shape: {nil, 1, 28, 28})
|> Axon.flatten()
|> Axon.dense(128, activation: :relu)
|> Axon.dense(10, activation: :sigmoid)
state =
model
|> Axon.Loop.trainer(:categorical_cross_entropy, Axon.Optimizers.adam(0.01))
|> Axon.Loop.metric(:accuracy, "Accuracy")
|> Axon.Loop.validate(model, validation_data)
|> Axon.Loop.run(training_data, %{}, compiler: EXLA, epochs: 10)
model
|> Axon.Loop.evaluator()
|> Axon.Loop.metric(:accuracy, "Accuracy")
|> Axon.Loop.run(test_data, state)
first_number = Enum.at(train_x, 0)[0]
Axon.predict(model, state, first_number)
from axon.
Ah, sorry, I didn't notice the notation. I use a screen reader and was only listening to the first few numbers of every tensor (it takes a long time for screen reader to read all those numbers). It turns out I never reached the end of any tensor, there the scientific notation is written..
from axon.
Could you share the full code?
from axon.
What's the Axon version used?
from axon.
With Axon 0.6 and EXLA 0.6, I got this output:
#Nx.Tensor<
f32[1][10]
EXLA.Backend<host:0, 0.3007448411.1655570452.243887>
[
[2.3431260944184697e-23, 4.296128036651581e-11, 1.0659236316176752e-17, 0.9999992847442627, 6.712944780263512e-22, 1.0, 2.8145804840526482e-22, 2.4531429665408666e-10, 9.463095196338145e-9, 2.6594868813845096e-6]
]
>
Maybe the confusion stems from the scientific notation?
All but the 4th number there are far smaller than 1. Note the e-23
suffix to the first entry. That means that it's 2.34... * 10 ** -23
. Likewise, the second is 4.29 * 10 ** -11
and so on.
from axon.
Related Issues (20)
- Online deep learning in Axon HOT 2
- Compiled model will always result in `%Axon.None{}`
- Block with multiple inputs fails to compile HOT 2
- mixed precision policies cause bumblebee models to fail HOT 2
- Cannot return map from Axon.nx
- batch_norm states "mean" and "var" never updated HOT 1
- Optimize frozen parameter memory usage HOT 1
- Allow overriding layer metadata such as `:op` and `:op_name` for built-ins HOT 1
- XLA Slow operation alarms: "The operation took ..." HOT 1
- a
- Loss increasing with binary_cross_entropy above version 0.4.1 HOT 6
- Compile Error due to a type mismatch HOT 2
- Req usage in OTP 26 HOT 6
- Most `Axon.ModelState` functions should be `defn` or `deftransform`
- Merge model state updates into a single `Axon.ModelState` call
- Optionally return gradients / gradient state in train step
- Crash with mixed precision with new Nx
- Remove namespaces
- Can't pass multiple inputs in custom trainer functions HOT 3
- Ambiguous inputs should raise
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axon.