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
Hello, I've tried to export efficientnet_b0b. However, it failed.
The following is my code segment:
net = glcv2_get_model("efficientnet_b0b", pretrained=True)
net.hybridize()
x = np.zeros([1,3,224,244])
x = mx.nd.array(x)
net.forward(x)
net.export('efficientnet_b0b')
And the error message is as following:
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 915, in forward
return self._call_cached_op(x, *args)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 805, in _call_cached_op
self._build_cache(*args)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 757, in _build_cache
data, out = self._get_graph(*args)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 749, in _get_graph
out = self.hybrid_forward(symbol, *grouped_inputs, **params) # pylint: disable=no-value-for-parameter
File "/usr/local/lib/python2.7/dist-packages/gluoncv2/models/efficientnet.py", line 393, in hybrid_forward
x = self.features(x)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 548, in call
out = self.forward(*args)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 932, in forward
return self.hybrid_forward(symbol, x, *args, **params)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/nn/basic_layers.py", line 117, in hybrid_forward
x = block(x)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 548, in call
out = self.forward(*args)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 932, in forward
return self.hybrid_forward(symbol, x, *args, **params)
File "/usr/local/lib/python2.7/dist-packages/gluoncv2/models/efficientnet.py", line 274, in hybrid_forward
x = F.pad(x, mode="constant", pad_width=calc_tf_padding(x, kernel_size=3, strides=2), constant_value=0)
File "/usr/local/lib/python2.7/dist-packages/gluoncv2/models/efficientnet.py", line 43, in calc_tf_padding
height, width = x.shape[2:]
AttributeError: 'Symbol' object has no attribute 'shape'
Do you know how to modify it? Thanks
The text was updated successfully, but these errors were encountered:
Hi, yes, the current implementation of the TF-like EfficientNet models (models with b-suffix) does not allow hybridization. EfficientNet models without b-suffix don't have such a problem.
For the EfficientNet-b model, you need to exclude the calculation of x.shape in the calc_tf_padding function. This requires careful modification of the model script (the weights will be preserved.) I can’t do this right now due to lack of time.
The standard way in this situation is to analyze what values are obtained in these places during the debug of a non-hybridized network (they will be different depending on the size of the network input!) And pass the valid values of height and width to calc_tf_padding function.
Hello, I've tried to export efficientnet_b0b. However, it failed.
The following is my code segment:
net = glcv2_get_model("efficientnet_b0b", pretrained=True)
net.hybridize()
x = np.zeros([1,3,224,244])
x = mx.nd.array(x)
net.forward(x)
net.export('efficientnet_b0b')
And the error message is as following:
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 915, in forward
return self._call_cached_op(x, *args)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 805, in _call_cached_op
self._build_cache(*args)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 757, in _build_cache
data, out = self._get_graph(*args)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 749, in _get_graph
out = self.hybrid_forward(symbol, *grouped_inputs, **params) # pylint: disable=no-value-for-parameter
File "/usr/local/lib/python2.7/dist-packages/gluoncv2/models/efficientnet.py", line 393, in hybrid_forward
x = self.features(x)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 548, in call
out = self.forward(*args)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 932, in forward
return self.hybrid_forward(symbol, x, *args, **params)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/nn/basic_layers.py", line 117, in hybrid_forward
x = block(x)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 548, in call
out = self.forward(*args)
File "/usr/local/lib/python2.7/dist-packages/mxnet/gluon/block.py", line 932, in forward
return self.hybrid_forward(symbol, x, *args, **params)
File "/usr/local/lib/python2.7/dist-packages/gluoncv2/models/efficientnet.py", line 274, in hybrid_forward
x = F.pad(x, mode="constant", pad_width=calc_tf_padding(x, kernel_size=3, strides=2), constant_value=0)
File "/usr/local/lib/python2.7/dist-packages/gluoncv2/models/efficientnet.py", line 43, in calc_tf_padding
height, width = x.shape[2:]
AttributeError: 'Symbol' object has no attribute 'shape'
Do you know how to modify it? Thanks
The text was updated successfully, but these errors were encountered: