returnn icon indicating copy to clipboard operation
returnn copied to clipboard

Fix subset param import

Open curufinwe opened this issue 4 years ago • 6 comments

Fix bug where custom_parameter_importer = "subset" would not operate on parameters inside rec layers.

curufinwe avatar Dec 16 '20 13:12 curufinwe

See failing test, i.e. code style.

albertz avatar Dec 16 '20 13:12 albertz

There is one remaining warning that is not easily fixable: I import _SubnetworkRecCell to do an isinstance check. Can this warning be ignored or how should I fix that?

curufinwe avatar Dec 16 '20 14:12 curufinwe

Actually, we should not do it this way. We should introduce more generally a function iter_sub_layers on LayerBase. And this should be overridden by SubnetworkLayer and RecLayer. Also, _SubnetworkRecCell actually internally has several subnetworks, and you probably should iterate through all of them. Specifically, output_layers_net, input_layers_net and net. See get_layer_from_outside. At least for this use case, you probably want all. Btw, I'm not exactly sure whether there can be duplicates, and whether you want to care about that (keep track in some visited = set() var).

Note that this is a bit inconsistent to the behavior of get_sub_layer, though, which requires that the layer (output) also can be used (which is not the case for layers within a loop). Not sure if we should maybe introduce two separate functions iter_all_sub_layers vs iter_sub_layers or so. Or just do not care about that. TF would anyway tell you when you use it wrongly. So I would vote to just implement iter_sub_layers and iterate all.

albertz avatar Dec 16 '20 14:12 albertz

What is the state here?

albertz avatar Jan 20 '21 11:01 albertz

Note: There is now the function get_all_layers_deep, which can be used instead of iter_layers_recursively.

albertz avatar Apr 20 '21 14:04 albertz

Ok, I removed iter_layers_recursively now, and just used get_all_layers_deep.

@curufinwe @michelwi can you check it's ok, so that we can merge?

albertz avatar Apr 21 '21 08:04 albertz