You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While developing #2316, Scope.paths where capture via a new mechanism made for tabulate, such mechanism assumes that there is a 1:1 correspondence between path names and variable structure, however a couple of workarounds had to be made as it was found that this breaks under certain circumstances. Here are some minimal reproducible examples showing this unexpected behavior.
1. Lifted Modules
When using lifted Modules, Scope.path names use the following notation:
<transformation_name>(<module_name>)
So you get names like scan(ScanLSTMCell_0), whereas in the variable structure only ScanLSTMCell_0 appears. Code bellow shows the difference between a different paths names and the corresponding variable structure for nn.scan + LSTMCell example:
When reusing a module (calling the same module more that once) there is some weird behavior where path path might be wrong after the first call.
Using Setup
Code bellow creates a CNN module, that has a ConvBlock submodule that calls Conv. Here submodules are created during setup and CNN calls self.block twice.
Notice that the 'inside conv' path is empty the second time self.block is called.
Using nn.compact
If you use nn.compact instead of setup path names are wrong in a different way. Here block is instantiated inside CNN.__call__ at the beginning and used twice.
Case 1 is part of the functional core API so its not really an error, just a mismatch between the functional API and the Module API.
Case 2 was fixed by #2360.
While developing #2316,
Scope.path
s where capture via a new mechanism made fortabulate
, such mechanism assumes that there is a 1:1 correspondence between path names and variable structure, however a couple of workarounds had to be made as it was found that this breaks under certain circumstances. Here are some minimal reproducible examples showing this unexpected behavior.1. Lifted Modules
When using lifted Modules,
Scope.path
names use the following notation:So you get names like
scan(ScanLSTMCell_0)
, whereas in the variable structure onlyScanLSTMCell_0
appears. Code bellow shows the difference between a different paths names and the corresponding variable structure fornn.scan
+LSTMCell
example:Code
2. Module reuse
When reusing a module (calling the same module more that once) there is some weird behavior where path path might be wrong after the first call.
Using Setup
Code bellow creates a
CNN
module, that has aConvBlock
submodule that callsConv
. Here submodules are created during setup andCNN
callsself.block
twice.Code
Notice that the
'inside conv'
path is empty the second timeself.block
is called.Using nn.compact
If you use
nn.compact
instead of setup path names are wrong in a different way. Hereblock
is instantiated insideCNN.__call__
at the beginning and used twice.Code
Notice that now all path are wrong the second time around.
The text was updated successfully, but these errors were encountered: