Git Product home page Git Product logo

Comments (8)

jheek avatar jheek commented on April 27, 2024 1

I agree the shape argument is arbitrary. It also implies that we can only return a single tensor which is also arbitrary.

Note that Flax is using the initializers from jax.nn.initializers so that create some difficulty when we want to reuse those.

An alternative that is less invasive is the following:

Change the current param api:

def param(self, shape, init_fn):
  ...
  init_value = init_fn(rng, shape)

to:

def param(self[, shape=None], init_fn):
  if shape is None:
    init_value = init_fn(rng):
  else:
    init_value = init_fn(rng, shape)

from flax.

j-towns avatar j-towns commented on April 27, 2024

Isn't

def param(self, shape=None, init_fn):

a SyntaxError? Just wondering if there's a way around that...

from flax.

j-towns avatar j-towns commented on April 27, 2024

Note that Flax is using the initializers from jax.nn.initializers so that create some difficulty when we want to reuse those.

I think it's pretty straightforward to wrap the JAX initializers though.

from flax.

jheek avatar jheek commented on April 27, 2024

Isn't

def param(self, shape=None, init_fn):

a SyntaxError? Just wondering if there's a way around that...

Yes you have to implement some manual argument unpacking to get that working. With the brackets I meant the param method is basically overloaded so you have either

param(name, shape, init_fn)
or
param(name, init_fn)

we could also decide to give the second option a different name.

from flax.

avital avatar avital commented on April 27, 2024

from flax.

jekbradbury avatar jekbradbury commented on April 27, 2024

If both Flax and Haiku want a different jax.nn.initializers API we should maybe switch it...

from flax.

levskaya avatar levskaya commented on April 27, 2024

@jekbradbury - oh, do haiku peeps also want a different initializer api?

from flax.

avital avatar avital commented on April 27, 2024

This has been resolved (with an improved shape check) in #530

from flax.

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.