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 2018/10/22 21:52:11 UTC

[GitHub] Sun1992 opened a new issue #12911: mx.sym.concat is slower than using pointwise convolution

Sun1992 opened a new issue #12911: mx.sym.concat is slower than using pointwise convolution
URL: https://github.com/apache/incubator-mxnet/issues/12911
 
 
   I am implementing Inception Net and Mobilenet Net recently. I found a very confused problem. The concatenation takes more time than pointwise convolution layer while expanding the dimension of the layer. 
   First I try:
   `def Conv(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''):
       conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group,
           stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix))
       bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' %(name, suffix), fix_gamma=True, eps=0.000100)
       act = mx.sym.Activation(data=bn, act_type='relu', name='%s%s_relu' %(name, suffix))
       return act
   
   def get_symbol(num_classes=1000):
   
       data = mx.symbol.Variable(name="data")
   
       conv_1 = Conv(data, num_filter=32, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_1") # 224/112
       conv_2=Conv(conv_1, num_filter=32, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_2") # 112/112
   
   
       pool = mx.symbol.Pooling(name='pool6', data=conv_2, pooling_convention='full', global_pool=True, pool_type='avg')
   
       fc = mx.symbol.Convolution(name='fc', data=pool, num_filter=num_classes, pad=(0, 0), kernel=(1,1), stride=(1,1), no_bias=False)
       flatten = mx.symbol.Flatten(data=fc, name='flatten')
       loss = mx.symbol.SoftmaxOutput(data=flatten, name="softmax")
       return loss
   `
   The FPS is around 90.
   
   Then I tried:
   `def Conv(data, num_filter=1, kernel=(1, 1), stride=(1, 1), pad=(0, 0), num_group=1, name=None, suffix=''):
       conv = mx.sym.Convolution(data=data, num_filter=num_filter, kernel=kernel, num_group=num_group,
           stride=stride, pad=pad, no_bias=True, name='%s%s_conv2d' %(name, suffix))
       bn = mx.sym.BatchNorm(data=conv, name='%s%s_batchnorm' %(name, suffix), fix_gamma=True, eps=0.000100)
       act = mx.sym.Activation(data=bn, act_type='relu', name='%s%s_relu' %(name, suffix))
       return act
   
   def get_symbol(num_classes=1000):
   
       data = mx.symbol.Variable(name="data")
   
       conv_1 = Conv(data, num_filter=32, kernel=(3, 3), pad=(1, 1), stride=(2, 2), name="conv_1") # 224/112
       conv_2=Conv(conv_1, num_filter=16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_2") # 112/112
       conv_3=Conv(conv_2, num_filter=16, kernel=(1, 1), pad=(0, 0), stride=(1, 1), name="conv_3") # 112/112
       conv4=mx.sym.concat(conv_2,conv_3)
   
       pool = mx.symbol.Pooling(name='pool6', data=conv4, pooling_convention='full', global_pool=True, pool_type='avg')
   
       fc = mx.symbol.Convolution(name='fc', data=pool, num_filter=num_classes, pad=(0, 0), kernel=(1,1), stride=(1,1), no_bias=False)
       flatten = mx.symbol.Flatten(data=fc, name='flatten')
       loss = mx.symbol.SoftmaxOutput(data=flatten, name="softmax")
       return loss
   `
   The speed is around 75 FPS, much slower than previous one. If we didn't take the computation cost of concatenate, it should be faster than previous one. In many papers, the concatenate operation is considered as much faster than pointwise convolution. Is there a way to speed up concatenate operation?  Why is the concatenate operation slower?
   

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