Git Product home page Git Product logo

Comments (2)

seanmor5 avatar seanmor5 commented on August 23, 2024

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.

seanmor5 avatar seanmor5 commented on August 23, 2024

This is possible with blocks now

from axon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.