Esempio n. 1
0
def _ResizeBilinearGrad(op, grad):
    """The derivatives for bilinear resizing.

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

  Returns:
    The gradients w.r.t. the input.
  """
    # pylint: disable=protected-access
    grad0 = gen_image_ops._resize_bilinear_grad(
        grad, op.inputs[0], align_corners=op.get_attr("align_corners"))
    # pylint: enable=protected-access
    return [grad0, None]
Esempio n. 2
0
def _ResizeBilinearGrad(op, grad):
  """The derivatives for bilinear resizing.

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

  Returns:
    The gradients w.r.t. the input.
  """
  # pylint: disable=protected-access
  grad0 = gen_image_ops._resize_bilinear_grad(
      grad, op.inputs[0], align_corners=op.get_attr("align_corners"))
  # pylint: enable=protected-access
  return [grad0, None]
Esempio n. 3
0
def _ResizeBilinearGrad(op, grad):
  """The derivatives for bilinear resizing.

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

  Returns:
    The gradients w.r.t. the input.
  """
  allowed_types = [dtypes.float32, dtypes.float64]
  grad0 = None
  if op.inputs[0].dtype in allowed_types:
    # pylint: disable=protected-access
    grad0 = gen_image_ops._resize_bilinear_grad(grad, op.inputs[0])
    # pylint: enable=protected-access
  return [grad0, None]
Esempio n. 4
0
def _ResizeBilinearGrad(op, grad):
    """The derivatives for bilinear resizing.

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

  Returns:
    The gradients w.r.t. the input.
  """
    allowed_types = [dtypes.float32, dtypes.float64]
    grad0 = None
    if op.inputs[0].dtype in allowed_types:
        # pylint: disable=protected-access
        grad0 = gen_image_ops._resize_bilinear_grad(grad, op.inputs[0])
        # pylint: enable=protected-access
    return [grad0, None]
Esempio n. 5
0
 def _assertBackwardOpMatchesExpected(self,
                                      grads_np,
                                      input_shape=None,
                                      dtype=None,
                                      expected=None):
   if input_shape is None:
     self.fail("input_shape must be specified")
   if expected is None:
     self.fail("expected must be specified")
   with self.test_session() as sess, self.test_scope():
     dtype = dtype or np.float32
     grads = array_ops.placeholder(np.float32)
     resized = gen_image_ops._resize_bilinear_grad(
         grads,
         np.zeros([1, input_shape[0], input_shape[1], 1], dtype=dtype),
         align_corners=True)
     out = sess.run(resized, {grads: grads_np[np.newaxis, :, :, np.newaxis]})
     self.assertAllClose(expected[np.newaxis, :, :, np.newaxis], out)
Esempio n. 6
0
 def _assertBackwardOpMatchesExpected(self,
                                      grads_np,
                                      input_shape=None,
                                      dtype=None,
                                      expected=None):
     if input_shape is None:
         self.fail("input_shape must be specified")
     if expected is None:
         self.fail("expected must be specified")
     with self.test_session() as sess, self.test_scope():
         dtype = dtype or np.float32
         grads = array_ops.placeholder(np.float32)
         resized = gen_image_ops._resize_bilinear_grad(
             grads,
             np.zeros([1, input_shape[0], input_shape[1], 1], dtype=dtype),
             align_corners=True)
         out = sess.run(resized,
                        {grads: grads_np[np.newaxis, :, :, np.newaxis]})
         self.assertAllClose(expected[np.newaxis, :, :, np.newaxis], out)