Is it possible to checkpoint a linen.Module
instance?
#3145
Unanswered
alvinsunyixiao
asked this question in
Q&A
Replies: 1 comment 5 replies
-
Hey @alvinsunyixiao, since Flax Modules are dataclasses you can use import flax.linen as nn
import dataclasses
module = nn.Dense(10)
module_config = dataclasses.asdict(module)
print(module_config) Hope this helps! |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It could be useful to save some of the hyperparameters stored in a
linen.Module
instance to a checkpoint, but it looks likelinen.Module
is a ordinary dataclass instead of astruct.dataclass
. This means thatorbax
checkpoint API does not serialize alinen.Module
instance. Here is a code snippet of failing to save the model to a checkpoint.I tried the following changes
or
but neither of them worked. (I think the errors have something to do with Python dataclass inheritance problems)
Is there a way to make
model
also astruct.dataclass
? And / Or is there a way to save themodel
to a checkpoint?Beta Was this translation helpful? Give feedback.
All reactions