You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/08/31 05:47:29 UTC

[GitHub] jaewoosong opened a new issue #7681: ValueError: Data provided by data_shapes don't match names specified by data_names ([] vs. ['data'])

jaewoosong opened a new issue #7681: ValueError: Data provided by data_shapes don't match names specified by data_names ([] vs. ['data'])
URL: https://github.com/apache/incubator-mxnet/issues/7681
 
 
   For bugs or installation issues, please provide the following information.
   The more information you provide, the more likely people will be able to help you.
   
   ## Environment info
   Operating System: Ubuntu 16.04
   
   Compiler: Python 3.6.1 (Anaconda 4.4.0, 64bit), installed by pip
   
   Package used (Python/R/Scala/Julia): Python
   
   MXNet version: 0.11.0
   
   Python version and distribution: Python 3.6.1 (Anaconda 4.4.0, 64bit), installed by pip
   
   ## Error Message:
   ```
   Traceback (most recent call last):
     File "/home/jaewoo/temp2.py", line 63, in <module>
       mod.fit(data_iter, num_epoch=5)
     File "/home/jaewoo/Programs/anaconda3/lib/python3.6/site-packages/mxnet/module/base_module.py", line 487, in fit
       self.forward_backward(data_batch)
     File "/home/jaewoo/Programs/anaconda3/lib/python3.6/site-packages/mxnet/module/base_module.py", line 191, in forward_backward
       self.forward(data_batch, is_train=True)
     File "/home/jaewoo/Programs/anaconda3/lib/python3.6/site-packages/mxnet/module/module.py", line 594, in forward
       self.reshape(new_dshape, new_lshape)
     File "/home/jaewoo/Programs/anaconda3/lib/python3.6/site-packages/mxnet/module/module.py", line 457, in reshape
       self.data_names, self.label_names, data_shapes, label_shapes)
     File "/home/jaewoo/Programs/anaconda3/lib/python3.6/site-packages/mxnet/module/base_module.py", line 71, in _parse_data_desc
       _check_names_match(data_names, data_shapes, 'data', True)
     File "/home/jaewoo/Programs/anaconda3/lib/python3.6/site-packages/mxnet/module/base_module.py", line 63, in _check_names_match
       raise ValueError(msg)
   ValueError: Data provided by data_shapes don't match names specified by data_names ([] vs. ['data'])
   ```
   
   ## Minimum reproducible example
   ```
   import mxnet as mx
   import os
   import subprocess
   import numpy as np
   import matplotlib.pyplot as plt
   import tarfile
   
   import warnings
   warnings.filterwarnings("ignore", category=DeprecationWarning)
   
   class SimpleIter(mx.io.DataIter):
       def __init__(self, data_names, data_shapes, data_gen,
                    label_names, label_shapes, label_gen, num_batches=10):
           self._provide_data = zip(data_names, data_shapes)
           self._provide_label = zip(label_names, label_shapes)
           self.num_batches = num_batches
           self.data_gen = data_gen
           self.label_gen = label_gen
           self.cur_batch = 0
   
       def __iter__(self):
           return self
   
       def reset(self):
           self.cur_batch = 0
   
       def __next__(self):
           return self.next()
   
       @property
       def provide_data(self):
           return self._provide_data
   
       @property
       def provide_label(self):
           return self._provide_label
   
       def next(self):
           if self.cur_batch < self.num_batches:
               self.cur_batch += 1
               data = [mx.nd.array(g(d[1])) for d,g in zip(self._provide_data, self.data_gen)]
               label = [mx.nd.array(g(d[1])) for d,g in zip(self._provide_label, self.label_gen)]
               return mx.io.DataBatch(data, label)
           else:
               raise StopIteration
   
   num_classes = 10
   net = mx.sym.Variable('data')
   net = mx.sym.FullyConnected(data=net, name='fc1', num_hidden=64)
   net = mx.sym.Activation(data=net, name='relu1', act_type="relu")
   net = mx.sym.FullyConnected(data=net, name='fc2', num_hidden=num_classes)
   net = mx.sym.SoftmaxOutput(data=net, name='softmax')
   print(net.list_arguments())
   print(net.list_outputs())
   
   n = 32
   data_iter = SimpleIter(['data'], [(n, 100)],
                     [lambda s: np.random.uniform(-1, 1, s)],
                     ['softmax_label'], [(n,)],
                     [lambda s: np.random.randint(0, num_classes, s)])
   
   mod = mx.mod.Module(symbol=net)
   mod.fit(data_iter, num_epoch=5)
   ```
   Actually this code is same as the official mxnet tutorial. ( https://mxnet.incubator.apache.org/tutorials/basic/data.html )
   
   ## What have you tried to solve it?
   It seems `def _parse_data_desc(data_names, label_names, data_shapes, label_shapes)` and `def _check_names_match(data_names, data_shapes, name, throw)` have bugs.
 
----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services