Beispiel #1
0
def _DepthwiseConv2dNativeBackpropInputGrad(op, grad):
    """The derivatives for deconvolution.

  Args:
    op: the Deconvolution op.
    grad: the tensor representing the gradient w.r.t. the output

  Returns:
    the gradients w.r.t. the input and the filter
  """
    return [
        None,
        gen_nn_ops.depthwise_conv2d_native_backprop_filter(
            grad,
            array_ops.shape(op.inputs[1]),
            op.inputs[2],
            dilations=op.get_attr("dilations"),
            strides=op.get_attr("strides"),
            padding=op.get_attr("padding"),
            explicit_paddings=op.get_attr("explicit_paddings"),
            data_format=op.get_attr("data_format")),
        gen_nn_ops.depthwise_conv2d_native(
            grad,
            op.inputs[1],
            dilations=op.get_attr("dilations"),
            strides=op.get_attr("strides"),
            padding=op.get_attr("padding"),
            explicit_paddings=op.get_attr("explicit_paddings"),
            data_format=op.get_attr("data_format"))
    ]
Beispiel #2
0
def _DepthwiseConv2dNativeBackpropFilterGrad(op, grad):
    return [
        gen_nn_ops.depthwise_conv2d_native_backprop_input(
            array_ops.shape(op.inputs[0]),
            grad,
            op.inputs[2],
            dilations=op.get_attr("dilations"),
            strides=op.get_attr("strides"),
            padding=op.get_attr("padding"),
            explicit_paddings=op.get_attr("explicit_paddings"),
            data_format=op.get_attr("data_format")), None,
        gen_nn_ops.depthwise_conv2d_native(
            op.inputs[0],
            grad,
            dilations=op.get_attr("dilations"),
            strides=op.get_attr("strides"),
            padding=op.get_attr("padding"),
            explicit_paddings=op.get_attr("explicit_paddings"),
            data_format=op.get_attr("data_format"))
    ]