Equivalent of tf.nn.dilation2d

Hello,

I’m new to PyTorch and I don’t know too well Tensorflow. I am currently re-writting a code in Tensorflow to Pytorch and they use tf.nn.dilation2d. I didn’t find any function close to the tensorflow’s one. Can anyone help me ?

Thanks !

I don’t think a dilation is implemented yet.
You could unfold the image tensor and apply the max operation on each patch.
Have a look at this example to see how to create the patches.

Thank you ! I will look into it !

@cthnguyen have you figured out how to do this?

So how to tackle the gradient function of the structural element in the dialtion in the back propagation ?

So how to tackle the gradient function of the structural element in the dialtion in the back propagation ?

If you are using the unfold approach with an input tensor, which requires gradients, Autograd should be able to create the backward function automatically as long as you don’t detach the tensor from the computation graph.

thanks!But I am confused why the dilation operation in tensorflow explicitly defines a backpropagation, so if I customize the dilation in pytorch, don’t I?

I’m not sure, how Tensorflow is implemented in the backend, but note that in PyTorch also backward functions are implemented for you.
Autograd will call these functions, so that you don’t have to manually write them.

oh,I will try,thank you very much!