neulab/docprompting-conala huggingface dataset:
tf.keras.losses.binary_crossentropy     View source on GitHub    Computes the binary crossentropy loss.  View aliases  Main aliases 
tf.keras.metrics.binary_crossentropy, tf.losses.binary_crossentropy, tf.metrics.binary_crossentropy Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.binary_crossentropy, tf.compat.v1.keras.metrics.binary_crossentropy  
tf.keras.losses.binary_crossentropy(
    y_true, y_pred, from_logits=False, label_smoothing=0
)
 Standalone usage: 
y_true = [[0, 1], [0, 0]]
y_pred = [[0.6, 0.4], [0.4, 0.6]]
loss = tf.keras.losses.binary_crossentropy(y_true, y_pred)
assert loss.shape == (2,)
loss.numpy()
array([0.916 , 0.714], dtype=float32)

 


 Args
  y_true   Ground truth values. shape = [batch_size, d0, .. dN].  
  y_pred   The predicted values. shape = [batch_size, d0, .. dN].  
  from_logits   Whether y_pred is expected to be a logits tensor. By default, we assume that y_pred encodes a probability distribution.  
  label_smoothing   Float in [0, 1]. If > 0 then smooth the labels.   
 


 Returns   Binary crossentropy loss value. shape = [batch_size, d0, .. dN-1].
tf.keras.losses.categorical_crossentropy     View source on GitHub    Computes the categorical crossentropy loss.  View aliases  Main aliases 
tf.keras.metrics.categorical_crossentropy, tf.losses.categorical_crossentropy, tf.metrics.categorical_crossentropy Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.categorical_crossentropy, tf.compat.v1.keras.metrics.categorical_crossentropy  
tf.keras.losses.categorical_crossentropy(
    y_true, y_pred, from_logits=False, label_smoothing=0
)
 Standalone usage: 
y_true = [[0, 1, 0], [0, 0, 1]]
y_pred = [[0.05, 0.95, 0], [0.1, 0.8, 0.1]]
loss = tf.keras.losses.categorical_crossentropy(y_true, y_pred)
assert loss.shape == (2,)
loss.numpy()
array([0.0513, 2.303], dtype=float32)

 


 Args
  y_true   Tensor of one-hot true targets.  
  y_pred   Tensor of predicted targets.  
  from_logits   Whether y_pred is expected to be a logits tensor. By default, we assume that y_pred encodes a probability distribution.  
  label_smoothing   Float in [0, 1]. If > 0 then smooth the labels.   
 


 Returns   Categorical crossentropy loss value.
tf.keras.losses.categorical_hinge     View source on GitHub    Computes the categorical hinge loss between y_true and y_pred.  View aliases  Main aliases 
tf.losses.categorical_hinge Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.categorical_hinge  
tf.keras.losses.categorical_hinge(
    y_true, y_pred
)
 loss = maximum(neg - pos + 1, 0) where neg=maximum((1-y_true)*y_pred) and pos=sum(y_true*y_pred) Standalone usage: 
y_true = np.random.randint(0, 3, size=(2,))
y_true = tf.keras.utils.to_categorical(y_true, num_classes=3)
y_pred = np.random.random(size=(2, 3))
loss = tf.keras.losses.categorical_hinge(y_true, y_pred)
assert loss.shape == (2,)
pos = np.sum(y_true * y_pred, axis=-1)
neg = np.amax((1. - y_true) * y_pred, axis=-1)
assert np.array_equal(loss.numpy(), np.maximum(0., neg - pos + 1.))

 


 Args
  y_true   The ground truth values. y_true values are expected to be 0 or 1.  
  y_pred   The predicted values.   
 


 Returns   Categorical hinge loss values.
tf.keras.losses.cosine_similarity Computes the cosine similarity between labels and predictions.  View aliases  Main aliases 
tf.losses.cosine_similarity Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.cosine, tf.compat.v1.keras.losses.cosine_proximity, tf.compat.v1.keras.losses.cosine_similarity, tf.compat.v1.keras.metrics.cosine, tf.compat.v1.keras.metrics.cosine_proximity  
tf.keras.losses.cosine_similarity(
    y_true, y_pred, axis=-1
)
 Note that it is a number between -1 and 1. When it is a negative number between -1 and 0, 0 indicates orthogonality and values closer to -1 indicate greater similarity. The values closer to 1 indicate greater dissimilarity. This makes it usable as a loss function in a setting where you try to maximize the proximity between predictions and targets. If either y_true or y_pred is a zero vector, cosine similarity will be 0 regardless of the proximity between predictions and targets. loss = -sum(l2_norm(y_true) * l2_norm(y_pred)) Standalone usage: 
y_true = [[0., 1.], [1., 1.], [1., 1.]]
y_pred = [[1., 0.], [1., 1.], [-1., -1.]]
loss = tf.keras.losses.cosine_similarity(y_true, y_pred, axis=1)
loss.numpy()
array([-0., -0.999, 0.999], dtype=float32)

 


 Args
  y_true   Tensor of true targets.  
  y_pred   Tensor of predicted targets.  
  axis   Axis along which to determine similarity.   
 


 Returns   Cosine similarity tensor.
tf.keras.losses.deserialize     View source on GitHub    Deserializes a serialized loss class/function instance.  View aliases  Main aliases 
tf.losses.deserialize Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.deserialize  
tf.keras.losses.deserialize(
    name, custom_objects=None
)

 


 Arguments
  name   Loss configuration.  
  custom_objects   Optional dictionary mapping names (strings) to custom objects (classes and functions) to be considered during deserialization.   
 


 Returns   A Keras Loss instance or a loss function.
tf.keras.losses.get     View source on GitHub    Retrieves a Keras loss as a function/Loss class instance.  View aliases  Main aliases 
tf.losses.get Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.get  
tf.keras.losses.get(
    identifier
)
 The identifier may be the string name of a loss function or Loss class. 
loss = tf.keras.losses.get("categorical_crossentropy")
type(loss)
<class 'function'>
loss = tf.keras.losses.get("CategoricalCrossentropy")
type(loss)
<class '...tensorflow.python.keras.losses.CategoricalCrossentropy'>
 You can also specify config of the loss to this function by passing dict containing class_name and config as an identifier. Also note that the class_name must map to a Loss class 
identifier = {"class_name": "CategoricalCrossentropy",
              "config": {"from_logits": True} }
loss = tf.keras.losses.get(identifier)
type(loss)
<class '...tensorflow.python.keras.losses.CategoricalCrossentropy'>

 


 Arguments
  identifier   A loss identifier. One of None or string name of a loss function/class or loss configuration dictionary or a loss function or a loss class instance   
 


 Returns   A Keras loss as a function/ Loss class instance.  

 


 Raises
  ValueError   If identifier cannot be interpreted.
tf.keras.losses.KLD     View source on GitHub    Computes Kullback-Leibler divergence loss between y_true and y_pred.  View aliases  Main aliases 
tf.keras.losses.kl_divergence, tf.keras.losses.kld, tf.keras.losses.kullback_leibler_divergence, tf.keras.metrics.KLD, tf.keras.metrics.kl_divergence, tf.keras.metrics.kld, tf.keras.metrics.kullback_leibler_divergence, tf.losses.KLD, tf.losses.kl_divergence, tf.losses.kld, tf.losses.kullback_leibler_divergence, tf.metrics.KLD, tf.metrics.kl_divergence, tf.metrics.kld, tf.metrics.kullback_leibler_divergence Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.KLD, tf.compat.v1.keras.losses.kl_divergence, tf.compat.v1.keras.losses.kld, tf.compat.v1.keras.losses.kullback_leibler_divergence, tf.compat.v1.keras.metrics.KLD, tf.compat.v1.keras.metrics.kl_divergence, tf.compat.v1.keras.metrics.kld, tf.compat.v1.keras.metrics.kullback_leibler_divergence  
tf.keras.losses.KLD(
    y_true, y_pred
)
 loss = y_true * log(y_true / y_pred) See: https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence Standalone usage: 
y_true = np.random.randint(0, 2, size=(2, 3)).astype(np.float64)
y_pred = np.random.random(size=(2, 3))
loss = tf.keras.losses.kullback_leibler_divergence(y_true, y_pred)
assert loss.shape == (2,)
y_true = tf.keras.backend.clip(y_true, 1e-7, 1)
y_pred = tf.keras.backend.clip(y_pred, 1e-7, 1)
assert np.array_equal(
    loss.numpy(), np.sum(y_true * np.log(y_true / y_pred), axis=-1))

 


 Args
  y_true   Tensor of true targets.  
  y_pred   Tensor of predicted targets.   
 


 Returns   A Tensor with loss.  

 


 Raises
  TypeError   If y_true cannot be cast to the y_pred.dtype.
tf.keras.losses.log_cosh Logarithm of the hyperbolic cosine of the prediction error.  View aliases  Main aliases 
tf.keras.losses.logcosh, tf.keras.metrics.log_cosh, tf.keras.metrics.logcosh, tf.losses.log_cosh, tf.losses.logcosh, tf.metrics.log_cosh, tf.metrics.logcosh Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.log_cosh, tf.compat.v1.keras.losses.logcosh, tf.compat.v1.keras.metrics.log_cosh, tf.compat.v1.keras.metrics.logcosh  
tf.keras.losses.log_cosh(
    y_true, y_pred
)
 log(cosh(x)) is approximately equal to (x ** 2) / 2 for small x and to abs(x) - log(2) for large x. This means that 'logcosh' works mostly like the mean squared error, but will not be so strongly affected by the occasional wildly incorrect prediction. Standalone usage: 
y_true = np.random.random(size=(2, 3))
y_pred = np.random.random(size=(2, 3))
loss = tf.keras.losses.logcosh(y_true, y_pred)
assert loss.shape == (2,)
x = y_pred - y_true
assert np.allclose(
    loss.numpy(),
    np.mean(x + np.log(np.exp(-2. * x) + 1.) - math_ops.log(2.), axis=-1),
    atol=1e-5)

 


 Args
  y_true   Ground truth values. shape = [batch_size, d0, .. dN].  
  y_pred   The predicted values. shape = [batch_size, d0, .. dN].   
 


 Returns   Logcosh error values. shape = [batch_size, d0, .. dN-1].
tf.keras.losses.MAE     View source on GitHub    Computes the mean absolute error between labels and predictions.  View aliases  Main aliases 
tf.keras.losses.mae, tf.keras.losses.mean_absolute_error, tf.keras.metrics.MAE, tf.keras.metrics.mae, tf.keras.metrics.mean_absolute_error, tf.losses.MAE, tf.losses.mae, tf.losses.mean_absolute_error, tf.metrics.MAE, tf.metrics.mae, tf.metrics.mean_absolute_error Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.MAE, tf.compat.v1.keras.losses.mae, tf.compat.v1.keras.losses.mean_absolute_error, tf.compat.v1.keras.metrics.MAE, tf.compat.v1.keras.metrics.mae, tf.compat.v1.keras.metrics.mean_absolute_error  
tf.keras.losses.MAE(
    y_true, y_pred
)
 loss = mean(abs(y_true - y_pred), axis=-1) Standalone usage: 
y_true = np.random.randint(0, 2, size=(2, 3))
y_pred = np.random.random(size=(2, 3))
loss = tf.keras.losses.mean_absolute_error(y_true, y_pred)
assert loss.shape == (2,)
assert np.array_equal(
    loss.numpy(), np.mean(np.abs(y_true - y_pred), axis=-1))

 


 Args
  y_true   Ground truth values. shape = [batch_size, d0, .. dN].  
  y_pred   The predicted values. shape = [batch_size, d0, .. dN].   
 


 Returns   Mean absolute error values. shape = [batch_size, d0, .. dN-1].
tf.keras.losses.MAPE     View source on GitHub    Computes the mean absolute percentage error between y_true and y_pred.  View aliases  Main aliases 
tf.keras.losses.mape, tf.keras.losses.mean_absolute_percentage_error, tf.keras.metrics.MAPE, tf.keras.metrics.mape, tf.keras.metrics.mean_absolute_percentage_error, tf.losses.MAPE, tf.losses.mape, tf.losses.mean_absolute_percentage_error, tf.metrics.MAPE, tf.metrics.mape, tf.metrics.mean_absolute_percentage_error Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.MAPE, tf.compat.v1.keras.losses.mape, tf.compat.v1.keras.losses.mean_absolute_percentage_error, tf.compat.v1.keras.metrics.MAPE, tf.compat.v1.keras.metrics.mape, tf.compat.v1.keras.metrics.mean_absolute_percentage_error  
tf.keras.losses.MAPE(
    y_true, y_pred
)
 loss = 100 * mean(abs((y_true - y_pred) / y_true), axis=-1) Standalone usage: 
y_true = np.random.random(size=(2, 3))
y_true = np.maximum(y_true, 1e-7)  # Prevent division by zero
y_pred = np.random.random(size=(2, 3))
loss = tf.keras.losses.mean_absolute_percentage_error(y_true, y_pred)
assert loss.shape == (2,)
assert np.array_equal(
    loss.numpy(),
    100. * np.mean(np.abs((y_true - y_pred) / y_true), axis=-1))

 


 Args
  y_true   Ground truth values. shape = [batch_size, d0, .. dN].  
  y_pred   The predicted values. shape = [batch_size, d0, .. dN].   
 


 Returns   Mean absolute percentage error values. shape = [batch_size, d0, .. dN-1].
tf.keras.losses.MSE     View source on GitHub    Computes the mean squared error between labels and predictions.  View aliases  Main aliases 
tf.keras.losses.mean_squared_error, tf.keras.losses.mse, tf.keras.metrics.MSE, tf.keras.metrics.mean_squared_error, tf.keras.metrics.mse, tf.losses.MSE, tf.losses.mean_squared_error, tf.losses.mse, tf.metrics.MSE, tf.metrics.mean_squared_error, tf.metrics.mse Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.MSE, tf.compat.v1.keras.losses.mean_squared_error, tf.compat.v1.keras.losses.mse, tf.compat.v1.keras.metrics.MSE, tf.compat.v1.keras.metrics.mean_squared_error, tf.compat.v1.keras.metrics.mse  
tf.keras.losses.MSE(
    y_true, y_pred
)
 After computing the squared distance between the inputs, the mean value over the last dimension is returned. loss = mean(square(y_true - y_pred), axis=-1) Standalone usage: 
y_true = np.random.randint(0, 2, size=(2, 3))
y_pred = np.random.random(size=(2, 3))
loss = tf.keras.losses.mean_squared_error(y_true, y_pred)
assert loss.shape == (2,)
assert np.array_equal(
    loss.numpy(), np.mean(np.square(y_true - y_pred), axis=-1))

 


 Args
  y_true   Ground truth values. shape = [batch_size, d0, .. dN].  
  y_pred   The predicted values. shape = [batch_size, d0, .. dN].   
 


 Returns   Mean squared error values. shape = [batch_size, d0, .. dN-1].
tf.keras.losses.MSLE     View source on GitHub    Computes the mean squared logarithmic error between y_true and y_pred.  View aliases  Main aliases 
tf.keras.losses.mean_squared_logarithmic_error, tf.keras.losses.msle, tf.keras.metrics.MSLE, tf.keras.metrics.mean_squared_logarithmic_error, tf.keras.metrics.msle, tf.losses.MSLE, tf.losses.mean_squared_logarithmic_error, tf.losses.msle, tf.metrics.MSLE, tf.metrics.mean_squared_logarithmic_error, tf.metrics.msle Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.MSLE, tf.compat.v1.keras.losses.mean_squared_logarithmic_error, tf.compat.v1.keras.losses.msle, tf.compat.v1.keras.metrics.MSLE, tf.compat.v1.keras.metrics.mean_squared_logarithmic_error, tf.compat.v1.keras.metrics.msle  
tf.keras.losses.MSLE(
    y_true, y_pred
)
 loss = mean(square(log(y_true + 1) - log(y_pred + 1)), axis=-1) Standalone usage: 
y_true = np.random.randint(0, 2, size=(2, 3))
y_pred = np.random.random(size=(2, 3))
loss = tf.keras.losses.mean_squared_logarithmic_error(y_true, y_pred)
assert loss.shape == (2,)
y_true = np.maximum(y_true, 1e-7)
y_pred = np.maximum(y_pred, 1e-7)
assert np.allclose(
    loss.numpy(),
    np.mean(
        np.square(np.log(y_true + 1.) - np.log(y_pred + 1.)), axis=-1))

 


 Args
  y_true   Ground truth values. shape = [batch_size, d0, .. dN].  
  y_pred   The predicted values. shape = [batch_size, d0, .. dN].   
 


 Returns   Mean squared logarithmic error values. shape = [batch_size, d0, .. dN-1].
tf.keras.losses.Poisson     View source on GitHub    Computes the Poisson loss between y_true and y_pred. Inherits From: Loss  View aliases  Main aliases 
tf.losses.Poisson Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.Poisson  
tf.keras.losses.Poisson(
    reduction=losses_utils.ReductionV2.AUTO, name='poisson'
)
 loss = y_pred - y_true * log(y_pred) Standalone usage: 
y_true = [[0., 1.], [0., 0.]]
y_pred = [[1., 1.], [0., 0.]]
# Using 'auto'/'sum_over_batch_size' reduction type.
p = tf.keras.losses.Poisson()
p(y_true, y_pred).numpy()
0.5
 
# Calling with 'sample_weight'.
p(y_true, y_pred, sample_weight=[0.8, 0.2]).numpy()
0.4
 
# Using 'sum' reduction type.
p = tf.keras.losses.Poisson(
    reduction=tf.keras.losses.Reduction.SUM)
p(y_true, y_pred).numpy()
0.999
 
# Using 'none' reduction type.
p = tf.keras.losses.Poisson(
    reduction=tf.keras.losses.Reduction.NONE)
p(y_true, y_pred).numpy()
array([0.999, 0.], dtype=float32)
 Usage with the compile() API: model.compile(optimizer='sgd', loss=tf.keras.losses.Poisson())

 


 Args
  reduction   (Optional) Type of tf.keras.losses.Reduction to apply to loss. Default value is AUTO. AUTO indicates that the reduction option will be determined by the usage context. For almost all cases this defaults to SUM_OVER_BATCH_SIZE. When used with tf.distribute.Strategy, outside of built-in training loops such as tf.keras compile and fit, using AUTO or SUM_OVER_BATCH_SIZE will raise an error. Please see this custom training tutorial for more details.  
  name   Optional name for the op. Defaults to 'poisson'.    Methods from_config View source 
@classmethod
from_config(
    config
)
 Instantiates a Loss from its config (output of get_config()).
 


 Args
  config   Output of get_config().   
 


 Returns   A Loss instance.  
 get_config View source 
get_config()
 Returns the config dictionary for a Loss instance. __call__ View source 
__call__(
    y_true, y_pred, sample_weight=None
)
 Invokes the Loss instance.
 


 Args
  y_true   Ground truth values. shape = [batch_size, d0, .. dN], except sparse loss functions such as sparse categorical crossentropy where shape = [batch_size, d0, .. dN-1]  
  y_pred   The predicted values. shape = [batch_size, d0, .. dN]  
  sample_weight   Optional sample_weight acts as a coefficient for the loss. If a scalar is provided, then the loss is simply scaled by the given value. If sample_weight is a tensor of size [batch_size], then the total loss for each sample of the batch is rescaled by the corresponding element in the sample_weight vector. If the shape of sample_weight is [batch_size, d0, .. dN-1] (or can be broadcasted to this shape), then each loss element of y_pred is scaled by the corresponding value of sample_weight. (Note ondN-1: all loss functions reduce by 1 dimension, usually axis=-1.)   
 


 Returns   Weighted loss float Tensor. If reduction is NONE, this has shape [batch_size, d0, .. dN-1]; otherwise, it is scalar. (Note dN-1 because all loss functions reduce by 1 dimension, usually axis=-1.)  

 


 Raises
  ValueError   If the shape of sample_weight is invalid.
tf.keras.losses.Reduction Types of loss reduction.  View aliases  Main aliases 
tf.losses.Reduction  Contains the following values:  
AUTO: Indicates that the reduction option will be determined by the usage context. For almost all cases this defaults to SUM_OVER_BATCH_SIZE. When used with tf.distribute.Strategy, outside of built-in training loops such as tf.keras compile and fit, we expect reduction value to be SUM or NONE. Using AUTO in that case will raise an error. 
NONE: Weighted losses with one dimension reduced (axis=-1, or axis specified by loss function). When this reduction type used with built-in Keras training loops like fit/evaluate, the unreduced vector loss is passed to the optimizer but the reported loss will be a scalar value. 
SUM: Scalar sum of weighted losses. 
SUM_OVER_BATCH_SIZE: Scalar SUM divided by number of elements in losses. This reduction type is not supported when used with tf.distribute.Strategy outside of built-in training loops like tf.keras compile/fit. You can implement 'SUM_OVER_BATCH_SIZE' using global batch size like: with strategy.scope():
  loss_obj = tf.keras.losses.CategoricalCrossentropy(
      reduction=tf.keras.losses.Reduction.NONE)
  ....
  loss = tf.reduce_sum(loss_obj(labels, predictions)) *
      (1. / global_batch_size)

  Please see the custom training guide for more details on this. Methods all View source 
@classmethod
all()
 validate View source 
@classmethod
validate(
    key
)

 


 Class Variables
  AUTO   'auto'  
  NONE   'none'  
  SUM   'sum'  
  SUM_OVER_BATCH_SIZE   'sum_over_batch_size'
tf.keras.losses.serialize     View source on GitHub    Serializes loss function or Loss instance.  View aliases  Main aliases 
tf.losses.serialize Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.serialize  
tf.keras.losses.serialize(
    loss
)

 


 Arguments
  loss   A Keras Loss instance or a loss function.   
 


 Returns   Loss configuration dictionary.
tf.keras.losses.sparse_categorical_crossentropy     View source on GitHub    Computes the sparse categorical crossentropy loss.  View aliases  Main aliases 
tf.keras.metrics.sparse_categorical_crossentropy, tf.losses.sparse_categorical_crossentropy, tf.metrics.sparse_categorical_crossentropy Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.sparse_categorical_crossentropy, tf.compat.v1.keras.metrics.sparse_categorical_crossentropy  
tf.keras.losses.sparse_categorical_crossentropy(
    y_true, y_pred, from_logits=False, axis=-1
)
 Standalone usage: 
y_true = [1, 2]
y_pred = [[0.05, 0.95, 0], [0.1, 0.8, 0.1]]
loss = tf.keras.losses.sparse_categorical_crossentropy(y_true, y_pred)
assert loss.shape == (2,)
loss.numpy()
array([0.0513, 2.303], dtype=float32)

 


 Args
  y_true   Ground truth values.  
  y_pred   The predicted values.  
  from_logits   Whether y_pred is expected to be a logits tensor. By default, we assume that y_pred encodes a probability distribution.  
  axis   (Optional) Defaults to -1. The dimension along which the entropy is computed.   
 


 Returns   Sparse categorical crossentropy loss value.
tf.keras.losses.squared_hinge     View source on GitHub    Computes the squared hinge loss between y_true and y_pred.  View aliases  Main aliases 
tf.keras.metrics.squared_hinge, tf.losses.squared_hinge, tf.metrics.squared_hinge Compat aliases for migration See Migration guide for more details. tf.compat.v1.keras.losses.squared_hinge, tf.compat.v1.keras.metrics.squared_hinge  
tf.keras.losses.squared_hinge(
    y_true, y_pred
)
 loss = mean(square(maximum(1 - y_true * y_pred, 0)), axis=-1) Standalone usage: 
y_true = np.random.choice([-1, 1], size=(2, 3))
y_pred = np.random.random(size=(2, 3))
loss = tf.keras.losses.squared_hinge(y_true, y_pred)
assert loss.shape == (2,)
assert np.array_equal(
    loss.numpy(),
    np.mean(np.square(np.maximum(1. - y_true * y_pred, 0.)), axis=-1))

 


 Args
  y_true   The ground truth values. y_true values are expected to be -1 or 1. If binary (0 or 1) labels are provided we will convert them to -1 or 1. shape = [batch_size, d0, .. dN].  
  y_pred   The predicted values. shape = [batch_size, d0, .. dN].   
 


 Returns   Squared hinge loss values. shape = [batch_size, d0, .. dN-1].