How To Load A Layer From Checkpoint
Solution 1:
This is currently not possible with preload_from_files
in this way.
So I currently see these possible options:
We could extend the logic of
preload_from_files
(andCustomCheckpointLoader
) to allow for sth like that (some generic variable/layer name mapping).Or you could rename your layer from
source_embed_raw
to e.g.old_model__target_embed_raw
and then usepreload_from_files
with theprefix
option. If you do not want to rename it, you could still add a layer likeold_model__target_embed_raw
and then use parameter sharing insource_embed_raw
.If the parameter in the checkpoint is actually called sth like
output/rec/target_embed_raw/...
, you could create aSubnetworkLayer
namedold_model__output
, in that anotherSubnetworkLayer
with namerec
, and in that a layer namedtarget_embed_raw
.You could write a script to simply load the existing checkpoint, and store is as a new checkpoint but with renamed variable names (this is also totally independent from RETURNN).
LinearLayer
(and most other layers) allows to specify exactly how the parameters are initialized (forward_weights_init
andbias_init
). The parameter initialization is quite flexible. E.g. there is sth likeload_txt_file_initializer
which can be used. Currently there is no such function to directly load it from an existing checkpoint but we could add that. Or you could simply implement the logic inside your config (it will only be sth like 5 lines of code or so).Instead of using
preload_from_files
, you could also useSubnetworkLayer
and theload_on_init
option. And then a similar logic as in option 2.
Post a Comment for "How To Load A Layer From Checkpoint"