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_rawto e.g.old_model__target_embed_rawand then usepreload_from_fileswith theprefixoption. If you do not want to rename it, you could still add a layer likeold_model__target_embed_rawand 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 aSubnetworkLayernamedold_model__output, in that anotherSubnetworkLayerwith 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_initandbias_init). The parameter initialization is quite flexible. E.g. there is sth likeload_txt_file_initializerwhich 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 useSubnetworkLayerand theload_on_initoption. And then a similar logic as in option 2.
Post a Comment for "How To Load A Layer From Checkpoint"