(feature_maps)
return matrix / denominator
Computes the Gram matrix for a set of feature maps.
Computes the Gram matrix for a set of feature maps.
Computes the Gram matrix for a set of feature maps .
def gram_matrix(feature_maps):
  """Computes the Gram matrix for a set of feature maps."""
  batch_size, height, width, channels = tf.unstack(tf.shape(feature_maps))
  denominator = tf.to_float(height * width)
  feature_maps = tf.reshape(
      feature_maps, tf.stack([batch_size, height * width, channels]))
  matrix = tf.matmul(feature_maps, feature_maps, adjoint_a=True)
  return matrix / denominator
def gram_matrix ( feature_maps ) : batch_size , height , width , channels = tf . unstack ( tf . shape ( feature_maps ) ) denominator = tf . to_float ( height * width ) feature_maps = tf . reshape ( feature_maps , tf . stack ( [ batch_size , height * width , channels ] ) ) matrix = tf . matmul ( feature_maps , feature_maps , adjoint_a = True ) return matrix / denominator