def get_bprop_conv3d_transpose(self): """Grad definition for `Conv3DTranspose` operation.""" input_grad = nps.Conv3D(out_channel=self.in_channel, kernel_size=self.kernel_size, mode=self.mode, pad_mode="pad", pad=self.pad, stride=self.stride, dilation=self.dilation, group=self.group, data_format=self.data_format) filter_grad = G.Conv3DBackpropFilter(out_channel=self.in_channel, kernel_size=self.kernel_size, mode=self.mode, pad_mode="pad", pad=self.pad, stride=self.stride, dilation=self.dilation, group=self.group, data_format=self.data_format) def bprop(x, w, out, dout): dx = input_grad(dout, w) dw = filter_grad(dout, x, F.shape(w)) return dx, dw, zeros_like(out) return bprop
def __init__(self, in_channel, out_channel, kernel_size, mode=1, pad_mode="valid", pad=0, stride=1, dilation=1, group=1, data_format="NCDHW", bias_init="zeros", has_bias=True): super().__init__() self.weight_shape = (out_channel, in_channel, kernel_size[0], kernel_size[1], kernel_size[2]) self.weight = weight_variable(self.weight_shape) self.conv = nps.Conv3D(out_channel=out_channel, kernel_size=kernel_size, mode=mode, \ pad_mode=pad_mode, pad=pad, stride=stride, dilation=dilation, \ group=group, data_format=data_format) self.bias_init = bias_init self.has_bias = has_bias self.bias_add = P.BiasAdd(data_format=data_format) if self.has_bias: self.bias = Parameter(initializer(self.bias_init, [out_channel]), name='bias')