-
Notifications
You must be signed in to change notification settings - Fork 226
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
In haiku, is there something equivalent to flax.nn.Model? #69
Comments
haiku
, is there something equivalent to flax.nn.Model
?
Haiku doesn't offers a Model interface. You can try Elegy which offers a Keras-like Model interface, however since version |
thanks for the tip, @cgarciae ! Just for my own curiosity, is there any feature available in |
@TuanNguyen27 From the base implementation of the |
We don't ship a model interface in Haiku (in general we try to be un-opinionated wrt how you use your neural network), but you can write a small wrapper class if you want to hold your apply function and parameters as an object: @dataclass
class Model:
params: hk.Params
apply: Callable
def __call__(self, x):
return self.apply(self.params, x)
model = Model(params, f.apply)
print(model.params)
out = model(x) |
Thanks for creating such a nice library!
My example use case in
flax
:With this, i can call
model(x)
and i can also access current params viamodel.params
.For
haiku
I can do
partial_fun(x)
but becausepartial_fun
is a lambda, i can't accessnn_params
frompartial_fun
. Wondering if there's any workaround to achieve this inhaiku
.For more context, I am trying to integrate
haiku
withnumpyro
so that we can convert traditional NN into Bayesian NN. You can see this issue pyro-ppl/numpyro#705 for more context, or this example notebookThe text was updated successfully, but these errors were encountered: