Hello, I have faced an issue in model loading while trying to load ResNet-like model. The simplest steps to reproduce I found is to use the following model:
This produces the following error during loading from saved weights:
File "<...>/neon/models/model.py", line 177, in fit
callbacks.on_train_begin(num_epochs)
File "<...>/neon/callbacks/callbacks.py", line 267, in on_train_begin
self.model().load_params(self.model_file)
File "<...>/neon/models/model.py", line 418, in load_params
self.deserialize(load_obj(param_path), load_states=load_states)
File "<...>/neon/models/model.py", line 479, in deserialize
self.layers.load_weights(model_dict['model'], load_states)
File "<...>/neon/layers/container.py", line 199, in load_weights
pdict['config']['layers'] = self.fusion_pass(pdict['config']['layers'])
File "<...>/neon/layers/container.py", line 178, in fusion_pass
if any([pattern(l1, l2) for pattern in patterns]): #if (l1 is not None and l2 is not None)
File "<...>/neon/layers/container.py", line 178, in <listcomp>
if any([pattern(l1, l2) for pattern in patterns]): #if (l1 is not None and l2 is not None)
File "<...>/neon/layers/container.py", line 172, in <lambda>
y['type'] == 'neon.layers.layer.Bias']
TypeError: 'NoneType' object is not subscriptable
This line, which calls pattern function on the None value of l2;
The single layer in saved model layers list. This is not rare in ResNet-like models because of projection residual connections, which are saved by MergeSum (used for branches concatenation) as a separate layer list.
The solution I found is to skip pairs with None values:
if any([pattern(l1, l2) for pattern in patterns if (l1 is not None and l2 is not None)]):
Hello, I have faced an issue in model loading while trying to load ResNet-like model. The simplest steps to reproduce I found is to use the following model:
This produces the following error during loading from saved weights:
The key components of this problem is:
pairwise
function, which adds aNone
element to the list;None
value ofl2
;MergeSum
(used for branches concatenation) as a separate layer list.The solution I found is to skip pairs with
None
values:Environment: python 3.5.2, neon 2.6.0 (f9d771b).