(img1, img2)
return shape1, shape2, checks
Checks if two image tensors are compatible for metric computation.

  This function checks if two sets of images have ranks at least 3, and if the
  last three dimensions match.

  Args:
    img1: The first images tensor.
    img2: The second images tensor.

  Returns:
    A tuple of the first tensor shape, the second tensor shape, and a list of
    tf.Assert() implementing the checks.

  Raises:
    ValueError: when static shape check fails.
Checks if two image tensors are compatible for metric computation.
Checks if two image tensors are compatible for metric computation .
def verify_compatible_shapes(img1, img2):
  """Checks if two image tensors are compatible for metric computation.

  This function checks if two sets of images have ranks at least 3, and if the
  last three dimensions match.

  Args:
    img1: The first images tensor.
    img2: The second images tensor.

  Returns:
    A tuple of the first tensor shape, the second tensor shape, and a list of
    tf.Assert() implementing the checks.

  Raises:
    ValueError: when static shape check fails.
  """
  shape1 = img1.get_shape().with_rank_at_least(3)
  shape2 = img2.get_shape().with_rank_at_least(3)
  shape1[-3:].assert_is_compatible_with(shape2[-3:])

  if shape1.ndims is not None and shape2.ndims is not None:
    for dim1, dim2 in zip(reversed(shape1[:-3]), reversed(shape2[:-3])):
      if not (dim1 == 1 or dim2 == 1 or dim1.is_compatible_with(dim2)):
        raise ValueError(
            'Two images are not compatible: %s and %s' % (shape1, shape2))

  # Now assign shape tensors.
  shape1, shape2 = tf.shape_n([img1, img2])

  checks = []
  checks.append(tf.Assert(tf.greater_equal(tf.size(shape1), 3),
                          [shape1, shape2], summarize=10))
  checks.append(tf.Assert(tf.reduce_all(tf.equal(shape1[-3:], shape2[-3:])),
                          [shape1, shape2], summarize=10))
  return shape1, shape2, checks
def verify_compatible_shapes ( img1 , img2 ) : shape1 = img1 . get_shape ( ) . with_rank_at_least ( 3 ) shape2 = img2 . get_shape ( ) . with_rank_at_least ( 3 ) shape1 [ - 3 : ] . assert_is_compatible_with ( shape2 [ - 3 : ] ) if shape1 . ndims is not None and shape2 . ndims is not None : for dim1 , dim2 in zip ( reversed ( shape1 [ : - 3 ] ) , reversed ( shape2 [ : - 3 ] ) ) : if not ( dim1 == 1 or dim2 == 1 or dim1 . is_compatible_with ( dim2 ) ) : raise ValueError ( 'Two images are not compatible: %s and %s' % ( shape1 , shape2 ) ) # Now assign shape tensors. shape1 , shape2 = tf . shape_n ( [ img1 , img2 ] ) checks = [ ] checks . append ( tf . Assert ( tf . greater_equal ( tf . size ( shape1 ) , 3 ) , [ shape1 , shape2 ] , summarize = 10 ) ) checks . append ( tf . Assert ( tf . reduce_all ( tf . equal ( shape1 [ - 3 : ] , shape2 [ - 3 : ] ) ) , [ shape1 , shape2 ] , summarize = 10 ) ) return shape1 , shape2 , checks