keras-surgeon icon indicating copy to clipboard operation
keras-surgeon copied to clipboard

TypeError: 'NoneType' object cannot be interpreted as an integer

Open SherlockHua1995 opened this issue 5 years ago • 5 comments

Hello, when I used the delete_channels function to delete specific channels ,the following error occurred. model = delete_channels(model,final_prune_target[0][1],final_prune_target[0][2])

the final_prune_target: [['block3_conv1', <keras.layers.convolutional.Conv2D object at 0x7fd0da4389b0>, [137]],

File "/usr/local/lib/python3.5/dist-packages/kerassurgeon/operations.py", line 105, in delete_channels return surgeon.operate() File "/usr/local/lib/python3.5/dist-packages/kerassurgeon/surgeon.py", line 158, in operate self._mod_func_map[node](node, outputs, output_masks, **kwargs) File "/usr/local/lib/python3.5/dist-packages/kerassurgeon/surgeon.py", line 309, in _delete_channels new_delete_mask = self._make_delete_mask(old_layer, channels) File "/usr/local/lib/python3.5/dist-packages/kerassurgeon/surgeon.py", line 668, in _make_delete_mask new_delete_mask = np.ones(layer.output_shape[1:], dtype=bool) File "/usr/local/lib/python3.5/dist-packages/numpy/core/numeric.py", line 203, in ones a = empty(shape, dtype, order) TypeError: 'NoneType' object cannot be interpreted as an integer Any advice?Thanks a lot.

SherlockHua1995 avatar Apr 12 '19 02:04 SherlockHua1995

@SherlockHua1995 Have you solved the error? If you solved, Could you tell that how did you figure out? I also got this type of error. Thanks....

KathySwe avatar Jun 26 '19 10:06 KathySwe

hello,I have fixed this error for a long time so that I can't remember the details. I followed the error construction and check the functions called step after step. Good luck.

SherlockHua1995 avatar Jun 26 '19 13:06 SherlockHua1995

Can anyone help me out I am having the same issue

Sushant-aggarwal avatar Sep 29 '19 14:09 Sushant-aggarwal

@KathySwe @SherlockHua1995

Sushant-aggarwal avatar Sep 29 '19 14:09 Sushant-aggarwal

@Sushant-aggarwal Hi, I have met such issue and solved it. My case is that the model is dynamic input size, so make sure your model input size is fixed. Hope this will help.

pgr2015 avatar Oct 25 '19 08:10 pgr2015