This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
fail with parameters of size 1, tuple issue #9838
Closed
Description
I apologize in advance for creating an issue with little documentation to support it. But I have seen this problem with a new install of version 1.0.0 as recently as a week ago.
In essence, code in gluon/parameters.py seems to choke when a parameter is of size (1,). For example, a call to net.params.get() like the following will throw an error:
net.params.get('some_name', init= mx.init.Zero(), shape=(1,))
In these cases, in parameters.py, self._shape is not a tuple, so subsequent calls to zip() and other functions fail.
The fix I used was to make the following changes in gluon/parameters.py:
near line 151:
# the following two lines replace self._shape with a tuple
if isinstance(self._shape, tuple)==False:
self._shape = (self._shape,)
assert len(self._shape) == len(new_shape) and \
similarly near line 196:
if isinstance(self._shape, tuple)==False:
self._shape = (self._shape,)
for self_dim, data_dim in zip(self.shape, data.shape):
similarly near line 121:
def __repr__(self):
if isinstance(self._shape, tuple)==False:
self._shape = (self._shape,)
s = 'Parameter {name} (shape={shape}, dtype={dtype})'
John
Activity