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/06/24 03:20:48 UTC

[GitHub] [incubator-mxnet] smartwell opened a new issue #15338: About inference time problem

smartwell opened a new issue #15338: About inference time problem
URL: https://github.com/apache/incubator-mxnet/issues/15338
 
 
   i want to konw my code is correct ?
   ```
   class Basecnn(nn.HybridBlock):
   
       def __init__(self, **kwargs):
           super(Basecnn, self).__init__(**kwargs)
           self.block = nn.HybridSequential()
           self.block.add(
               nn.Conv2D(10, 3, 2, 1),
               nn.BatchNorm(),
               nn.LeakyReLU(0.25),
               # nn.Conv2DTranspose(32, 3, 2, 1, 1),
               nn.Dense(5),
           )
   
       def hybrid_forward(self,F, x):
           return self.block(x)
   
   data = mx.sym.Variable(name='data')
   net = Basecnn()
   net.hybridize()
   sym = net(data)
   
   data_names = ['data']
   
   ctx = mx.gpu()
   shape = [1, 3, 512, 512]
   
   mod = mx.mod.Module(symbol=sym, data_names=data_names, context=ctx, label_names=None)
   mod.bind(for_training=False,  data_shapes=[('data', tuple(shape))], label_shapes=None)
   mod.init_params()
   # mod.set_params(arg_params=arg, aux_params=aux,)
   
   randx = np.random.randint(0, 1, (1, 3, 512, 512))
   input_nd = mx.ndarray.array(randx, ctx)
   cc = mod.predict(input_nd).asnumpy()
   
   t0 = time.time()
   for i in range(1000):
       mod.predict(input_nd)
       prob = mod.get_outputs()[0].asnumpy()
   print('fps: ', 1000/(time.time()-t0))
   ```
   my computer GTX1080ti, i7-7700k, my fps is fps:  268.5
   but in Pytorch, fps is 1000+

----------------------------------------------------------------
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