szha commented on issue #7408: How to do a sobel operation in symbol layer
URL: 
https://github.com/apache/incubator-mxnet/issues/7408#issuecomment-321460822
 
 
   Something like this? The example is in ndarray but you can pass the kernel 
values in through `sym.var`.
   ```
   from mxnet import ndarray as nd
   
   data = nd.random_uniform(shape=(1, 1, 300, 300))
   
   kx = nd.array([[1, 2, 1]]).T * nd.array([[1, 0, -1]])
   ky = kx.T.reshape((1, 1, 3, 3))
   kx = kx.reshape((1, 1, 3, 3))
   
   gx = nd.Convolution(data, kx, kernel=(3, 3), num_filter=1, no_bias=True, 
layout='NCHW')
   gy = nd.Convolution(data, ky, kernel=(3, 3), num_filter=1, no_bias=True, 
layout='NCHW')
   
   out = nd.sqrt(gx*gx + gy*gy)
   ```
 
----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to