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/05/07 01:48:37 UTC

[GitHub] pribadihcr opened a new issue #10832: custom kernel

pribadihcr opened a new issue #10832: custom kernel
URL: https://github.com/apache/incubator-mxnet/issues/10832
 
 
   HI,
   How to make custom kernel for mxnet convolution like the following tf version:
   def gauss_kernel(kernlen=21, nsig=3, channels=1):
       interval = (2*nsig+1.)/(kernlen)
       x = np.linspace(-nsig-interval/2., nsig+interval/2., kernlen+1)
       kern1d = np.diff(st.norm.cdf(x))
       kernel_raw = np.sqrt(np.outer(kern1d, kern1d))
       kernel = kernel_raw/kernel_raw.sum()
       out_filter = np.array(kernel, dtype = np.float32)
       out_filter = out_filter.reshape((kernlen, kernlen, 1, 1))
       out_filter = np.repeat(out_filter, channels, axis = 2)
       return out_filter
   
   def blur(x):
       kernel_var = gauss_kernel(21, 3, 3)
       return tf.nn.depthwise_conv2d(x, kernel_var, [1, 1, 1, 1], padding='SAME')

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