You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/03/12 15:17:36 UTC

[GitHub] [incubator-mxnet] manasi198 opened a new issue #14400: training own model to own data in pascal voc format

manasi198 opened a new issue #14400: training own model to own data in pascal voc format
URL: https://github.com/apache/incubator-mxnet/issues/14400
 
 
   Note: Providing complete information in the most concise form is the best way to get help. This issue template serves as the checklist for essential information to most of the technical issues and bug reports. For non-technical issues and feature requests, feel free to present the information in what you believe is the best form.
   
   For Q & A and discussion, please start a discussion thread at https://discuss.mxnet.io 
   
   ## Description
    i have create a sample model to my own dataset in pascal voc format in mxnet but while running the net i am getting erre
   
   ## Environment info (Required)
   
   ```
   What to do:
   1. Download the diagnosis script from https://raw.githubusercontent.com/apache/incubator-mxnet/master/tools/diagnose.py
   2. Run the script using `python diagnose.py` and paste its output here.
   
   import mxnet as mx
   
   from mxnet import nd, gluon, init, autograd
   
   from mxnet import viz, sym
   from mxnet.gluon import nn
   from mxnet.gluon.data.vision import datasets, transforms
   
   import numpy as np
   import matplotlib.pyplot as plt
   
   from time import time
   classes= ['floor']
   from gluoncv.data import VOCDetection
   class VOCLike(VOCDetection):
       CLASSES = ['floor']
       def __init__(self, root, splits, transform=None, index_map=None, preload_label=True):
           super(VOCLike, self).__init__(root, splits, transform, index_map, preload_label)
   
   
   train = VOCLike(root='VOCtemplate', splits=((2018, 'train'),))
   valid_dataset=VOCLike(root='VOCtemplate', splits=((2018, 'val'),))
   print('length of dataset:', len(train))
   print('len_val',len(valid_dataset))
   print('label example:')
   c=0;
   batch_size = 4
   
   train_data = gluon.data.DataLoader(
       train, 
       batch_size=batch_size, 
       shuffle=True, 
       num_workers=0)
   
   ###print(len(train_data))
   val_data = gluon.data.DataLoader(
       valid_dataset, 
       batch_size=batch_size, 
       shuffle=True, 
       num_workers=0)
   
   ###print(len(val_data))
   
   print(train_data)
   
   for data,label in train_data:
         print(data.shape)  
   net = nn.Sequential()
   
   net.add(nn.Conv2D(channels=8, kernel_size=2, activation='relu'),
           nn.MaxPool2D(pool_size=2, strides=2),
           nn.Conv2D(channels=16, kernel_size=2, activation='relu'),
           nn.MaxPool2D(pool_size=2, strides=2),
           nn.Flatten(),
           nn.Dense(120, activation="relu"),
           nn.Dense(10))
   try:
       a = mx.nd.zeros((1,), ctx=mx.gpu(0))
       ctx = [mx.gpu(0)]
   except:
       ctx = [mx.cpu()]
   
   net.initialize(init=init.Xavier(),ctx=ctx)
   
   softmax_cross_entropy = gluon.loss.SoftmaxCrossEntropyLoss()
   
   trainer = gluon.Trainer(net.collect_params(), 'AdaGrad', {'learning_rate': 0.01})
   def acc(output, label):
       correct_preds = output.argmax(axis=1) == label.astype('float32')
       return correct_preds.mean().asscalar()
   
   for epoch in range(10):
       
       train_loss, train_acc, valid_acc = 0., 0., 0.
       tic = time()
   
       for data, label in train_data:
           data = data.copyto(mx.cpu(0))
           label = label.copyto(mx.cpu(0))
           with autograd.record():
               output = net(data)
               loss = softmax_cross_entropy(output, label)
   
           loss.backward()
   
           trainer.step(batch_size)
           
           train_loss += loss.mean().asscalar()
           train_acc += acc(output, label)
   
   Package used (Python/R/Scala/Julia):
   python 2.7
   
   For Scala user, please provide:
   1. Java version: (`java -version`)
   2. Maven version: (`mvn -version`)
   3. Scala runtime if applicable: (`scala -version`)
   
   For R user, please provide R `sessionInfo()`:
   
   ## Build info (Required if built from source)
   
   Compiler (gcc/clang/mingw/visual studio):
   
   MXNet commit hash:
   (Paste the output of `git rev-parse HEAD` here.)
   
   Build config:
   (Paste the content of config.mk, or the build command.)
   
   ## Error Message:
   (Paste the complete error message, including stack trace.)
   infer_shape error. Arguments:
     data: (4L, 512L, 512L, 3L)
   ---------------------------------------------------------------------------
   ValueError                                Traceback (most recent call last)
   <ipython-input-7-9926ba7deb21> in <module>()
        12         label = label.copyto(mx.cpu(0))
        13         with autograd.record():
   ---> 14             output = net(data)
        15             loss = softmax_cross_entropy(output, label)
        16 
   
   /home/manasi/.local/lib/python2.7/site-packages/mxnet/gluon/block.pyc in __call__(self, *args)
       539             hook(self, args)
       540 
   --> 541         out = self.forward(*args)
       542 
       543         for hook in self._forward_hooks.values():
   
   /home/manasi/.local/lib/python2.7/site-packages/mxnet/gluon/nn/basic_layers.pyc in forward(self, x)
        51     def forward(self, x):
        52         for block in self._children.values():
   ---> 53             x = block(x)
        54         return x
        55 
   
   /home/manasi/.local/lib/python2.7/site-packages/mxnet/gluon/block.pyc in __call__(self, *args)
       539             hook(self, args)
       540 
   --> 541         out = self.forward(*args)
       542 
       543         for hook in self._forward_hooks.values():
   
   /home/manasi/.local/lib/python2.7/site-packages/mxnet/gluon/block.pyc in forward(self, x, *args)
       911                     params = {i: j.data(ctx) for i, j in self._reg_params.items()}
       912                 except DeferredInitializationError:
   --> 913                     self._deferred_infer_shape(x, *args)
       914                     for _, i in self.params.items():
       915                         i._finish_deferred_init()
   
   /home/manasi/.local/lib/python2.7/site-packages/mxnet/gluon/block.pyc in _deferred_infer_shape(self, *args)
       792             error_msg = "Deferred initialization failed because shape"\
       793                         " cannot be inferred. {}".format(e)
   --> 794             raise ValueError(error_msg)
       795 
       796     def _call_cached_op(self, *args):
   
   ValueError: Deferred initialization failed because shape cannot be inferred. Error in operator conv2_fwd: [10:56:15] src/operator/nn/convolution.cc:196: Check failed: dilated_ksize_x <= AddPad(dshape[3], param_.pad[1]) (5 vs. 3) kernel size exceed input
   
   Stack trace returned 10 entries:
   [bt] (0) /home/manasi/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x1d86a2) [0x7fc5da5556a2]
   [bt] (1) /home/manasi/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x1d8cb8) [0x7fc5da555cb8]
   [bt] (2) /home/manasi/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x49a408) [0x7fc5da817408]
   [bt] (3) /home/manasi/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2bfc3bf) [0x7fc5dcf793bf]
   [bt] (4) /home/manasi/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(+0x2bfeed0) [0x7fc5dcf7bed0]
   [bt] (5) /home/manasi/.local/lib/python2.7/site-packages/mxnet/libmxnet.so(MXSymbolInferShape+0x1539) [0x7fc5dcef6969]
   [bt] (6) /home/manasi/anaconda2/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call_unix64+0x4c) [0x7fc615a80ec0]
   [bt] (7) /home/manasi/anaconda2/lib/python2.7/lib-dynload/../../libffi.so.6(ffi_call+0x22d) [0x7fc615a8087d]
   [bt] (8) /home/manasi/anaconda2/lib/python2.7/lib-dynload/_ctypes.so(_ctypes_callproc+0x4d6) [0x7fc615c968d6]
   [bt] (9) /home/manasi/anaconda2/lib/python2.7/lib-dynload/_ctypes.so(+0x8b31) [0x7fc615c8cb31]
   
   
   ## Minimum reproducible example
   (If you are using your own code, please provide a short script that reproduces the error. Otherwise, please provide link to the existing example.)
   
   ## Steps to reproduce
   (Paste the commands you ran that produced the error.)
   
   1.
   2.
   
   ## What have you tried to solve it?
   
   1.
   2.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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