Comments (2)
I've been experimenting a bit and after starting #81 I believe I have a solution to this issue. Introduce Axon.function
. The idea is that Axon.function
takes a block of layers with inputs and returns an anonymous function with arity matching the number of inputs in the block. So the GAN would look like:
generator =
Axon.input({nil, 100})
|> Axon.dense(128, activation: :tanh)
|> Axon.dense(512, activation: :tanh)
|> Axon.dense(784, activation: :tanh)
|> Axon.reshape({1, 28, 28})
|> Axon.function()
discriminator =
Axon.input({nil, 1, 28, 28})
|> Axon.dense(128, activation: :relu)
|> Axon.dense(1, activation: :sigmoid)
|> Axon.function()
joint = discriminator.(generator.(Axon.input({nil, 100}))
And generator and discriminator are still separate objects. The biggest question then becomes how do execution and compilation act when they encounter an Axon.function
.
Also note the reason we can't just do:
generator = fn x ->
x
|> Axon.dense(128, activation: :tanh)
|> Axon.dense(512, activation: :tanh)
|> Axon.dense(784, activation: :tanh)
|> Axon.reshape({1, 28, 28})
|> Axon.function()
end
discriminator = fn x ->
x
|> Axon.dense(128, activation: :relu)
|> Axon.dense(1, activation: :sigmoid)
|> Axon.function()
end
g = generator.(Axon.input({nil, 100})
d = discriminator.(Axon.input({nil, 784})
joint = discriminator.(generator.(Axon.input({nil, 100}))
is because of how Axon's compiler works. Subsequent calls to both generator and discriminator in the above yield brand new models with new uniquely named parameters rather than yielding the same model on each call - which is what Axon.function
would do.
from axon.
This is possible with blocks now
from axon.
Related Issues (20)
- 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
- Tagged versions missing in the repo compared to the ones in hexdocs.pm HOT 1
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.