John-Boik opened a new issue #9838: fail with parameters of size 1, tuple issue
URL: https://github.com/apache/incubator-mxnet/issues/9838
 
 
   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
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to