LostTech.TensorFlow : API Documentation

Type tf.keras.losses

Namespace tensorflow

Public static methods

Tensor binary_crossentropy(IGraphNodeBase y_true, IEnumerable<IGraphNodeBase> y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Tensor binary_crossentropy(IEnumerable<object> y_true, IEnumerable<IGraphNodeBase> y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Tensor binary_crossentropy(IEnumerable<object> y_true, IEnumerable<IGraphNodeBase> y_pred, bool from_logits, int label_smoothing)

Tensor binary_crossentropy(ValueTuple<IEnumerable<object>, object> y_true, IEnumerable<IGraphNodeBase> y_pred, bool from_logits, int label_smoothing)

Tensor binary_crossentropy(ValueTuple<IEnumerable<object>, object> y_true, IEnumerable<IGraphNodeBase> y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Tensor binary_crossentropy(ValueTuple<IEnumerable<object>, object> y_true, IGraphNodeBase y_pred, bool from_logits, int label_smoothing)

Tensor binary_crossentropy(IGraphNodeBase y_true, IEnumerable<IGraphNodeBase> y_pred, bool from_logits, int label_smoothing)

Tensor binary_crossentropy(IEnumerable<object> y_true, IGraphNodeBase y_pred, bool from_logits, int label_smoothing)

Tensor binary_crossentropy(IGraphNodeBase y_true, IGraphNodeBase y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Tensor binary_crossentropy(object y_true, IEnumerable<IGraphNodeBase> y_pred, bool from_logits, int label_smoothing)

Tensor binary_crossentropy(object y_true, IEnumerable<IGraphNodeBase> y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Tensor binary_crossentropy(ValueTuple<IEnumerable<object>, object> y_true, IGraphNodeBase y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Tensor binary_crossentropy(IGraphNodeBase y_true, IGraphNodeBase y_pred, bool from_logits, int label_smoothing)

Tensor binary_crossentropy(IndexedSlices y_true, IEnumerable<IGraphNodeBase> y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Tensor binary_crossentropy(IndexedSlices y_true, IEnumerable<IGraphNodeBase> y_pred, bool from_logits, int label_smoothing)

Tensor binary_crossentropy(object y_true, IGraphNodeBase y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Tensor binary_crossentropy(IEnumerable<object> y_true, IGraphNodeBase y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Tensor binary_crossentropy(IndexedSlices y_true, IGraphNodeBase y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Tensor binary_crossentropy(object y_true, IGraphNodeBase y_pred, bool from_logits, int label_smoothing)

Tensor binary_crossentropy(IndexedSlices y_true, IGraphNodeBase y_pred, bool from_logits, int label_smoothing)

object binary_crossentropy_dyn(object y_true, object y_pred, ImplicitContainer<T> from_logits, ImplicitContainer<T> label_smoothing)

Tensor categorical_crossentropy(object y_true, IGraphNodeBase y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Computes the categorical crossentropy loss.
Parameters
object y_true
tensor of true targets.
IGraphNodeBase y_pred
tensor of predicted targets.
bool from_logits
Whether `y_pred` is expected to be a logits tensor. By default, we assume that `y_pred` encodes a probability distribution.
IGraphNodeBase label_smoothing
Float in [0, 1]. If > `0` then smooth the labels.
Returns
Tensor
Categorical crossentropy loss value.

Tensor categorical_crossentropy(IGraphNodeBase y_true, IGraphNodeBase y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Computes the categorical crossentropy loss.
Parameters
IGraphNodeBase y_true
tensor of true targets.
IGraphNodeBase y_pred
tensor of predicted targets.
bool from_logits
Whether `y_pred` is expected to be a logits tensor. By default, we assume that `y_pred` encodes a probability distribution.
IGraphNodeBase label_smoothing
Float in [0, 1]. If > `0` then smooth the labels.
Returns
Tensor
Categorical crossentropy loss value.

Tensor categorical_crossentropy(IndexedSlices y_true, IGraphNodeBase y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Computes the categorical crossentropy loss.
Parameters
IndexedSlices y_true
tensor of true targets.
IGraphNodeBase y_pred
tensor of predicted targets.
bool from_logits
Whether `y_pred` is expected to be a logits tensor. By default, we assume that `y_pred` encodes a probability distribution.
IGraphNodeBase label_smoothing
Float in [0, 1]. If > `0` then smooth the labels.
Returns
Tensor
Categorical crossentropy loss value.

Tensor categorical_crossentropy(ValueTuple<IEnumerable<object>, object> y_true, IGraphNodeBase y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Computes the categorical crossentropy loss.
Parameters
ValueTuple<IEnumerable<object>, object> y_true
tensor of true targets.
IGraphNodeBase y_pred
tensor of predicted targets.
bool from_logits
Whether `y_pred` is expected to be a logits tensor. By default, we assume that `y_pred` encodes a probability distribution.
IGraphNodeBase label_smoothing
Float in [0, 1]. If > `0` then smooth the labels.
Returns
Tensor
Categorical crossentropy loss value.

Tensor categorical_crossentropy(IEnumerable<object> y_true, IGraphNodeBase y_pred, bool from_logits, IGraphNodeBase label_smoothing)

Computes the categorical crossentropy loss.
Parameters
IEnumerable<object> y_true
tensor of true targets.
IGraphNodeBase y_pred
tensor of predicted targets.
bool from_logits
Whether `y_pred` is expected to be a logits tensor. By default, we assume that `y_pred` encodes a probability distribution.
IGraphNodeBase label_smoothing
Float in [0, 1]. If > `0` then smooth the labels.
Returns
Tensor
Categorical crossentropy loss value.

object categorical_hinge(IGraphNodeBase y_true, IGraphNodeBase y_pred)

Computes the categorical hinge loss between `y_true` and `y_pred`.
Parameters
IGraphNodeBase y_true
The ground truth values. `y_true` values are expected to be -1 or 1. If binary (0 or 1) labels are provided they will be converted to -1 or 1.
IGraphNodeBase y_pred
The predicted values.
Returns
object
A tensor.

object categorical_hinge_dyn(object y_true, object y_pred)

Computes the categorical hinge loss between `y_true` and `y_pred`.
Parameters
object y_true
The ground truth values. `y_true` values are expected to be -1 or 1. If binary (0 or 1) labels are provided they will be converted to -1 or 1.
object y_pred
The predicted values.
Returns
object
A tensor.

Tensor cosine(IEnumerable<double> y_true, IGraphNodeBase y_pred, int axis)

Computes the cosine similarity between labels and predictions.

Tensor cosine(IEnumerable<double> y_true, IEnumerable<double> y_pred, int axis)

Computes the cosine similarity between labels and predictions.

Tensor cosine(IGraphNodeBase y_true, IGraphNodeBase y_pred, int axis)

Computes the cosine similarity between labels and predictions.

Tensor cosine(IGraphNodeBase y_true, IEnumerable<double> y_pred, int axis)

Computes the cosine similarity between labels and predictions.

object cosine_dyn(object y_true, object y_pred, ImplicitContainer<T> axis)

Computes the cosine similarity between labels and predictions.

Tensor hinge(IGraphNodeBase y_true, IGraphNodeBase y_pred)

Computes the hinge loss between `y_true` and `y_pred`.
Parameters
IGraphNodeBase y_true
The ground truth values. `y_true` values are expected to be -1 or 1. If binary (0 or 1) labels are provided they will be converted to -1 or 1.
IGraphNodeBase y_pred
The predicted values.
Returns
Tensor
Tensor with one scalar loss entry per sample.

object hinge_dyn(object y_true, object y_pred)

Computes the hinge loss between `y_true` and `y_pred`.
Parameters
object y_true
The ground truth values. `y_true` values are expected to be -1 or 1. If binary (0 or 1) labels are provided they will be converted to -1 or 1.
object y_pred
The predicted values.
Returns
object
Tensor with one scalar loss entry per sample.

Tensor KLD(IGraphNodeBase y_true, IGraphNodeBase y_pred)

Computes Kullback-Leibler divergence loss between `y_true` and `y_pred`.

`loss = y_true * log(y_true / y_pred)`

See: https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence

Usage:
Parameters
IGraphNodeBase y_true
Tensor of true targets.
IGraphNodeBase y_pred
Tensor of predicted targets.
Returns
Tensor
A `Tensor` with loss.
Show Example
loss = tf.keras.losses.KLD([.4,.9,.2], [.5,.8,.12])
            print('Loss: ', loss.numpy())  # Loss: 0.11891246 

object KLD_dyn(object y_true, object y_pred)

Computes Kullback-Leibler divergence loss between `y_true` and `y_pred`.

`loss = y_true * log(y_true / y_pred)`

See: https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence

Usage:
Parameters
object y_true
Tensor of true targets.
object y_pred
Tensor of predicted targets.
Returns
object
A `Tensor` with loss.
Show Example
loss = tf.keras.losses.KLD([.4,.9,.2], [.5,.8,.12])
            print('Loss: ', loss.numpy())  # Loss: 0.11891246 

Tensor logcosh(IGraphNodeBase y_true, IGraphNodeBase y_pred)

Logarithm of the hyperbolic cosine of the prediction error.

`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.
Parameters
IGraphNodeBase y_true
tensor of true targets.
IGraphNodeBase y_pred
tensor of predicted targets.
Returns
Tensor
Tensor with one scalar loss entry per sample.

Tensor logcosh(IndexedSlices y_true, IGraphNodeBase y_pred)

Logarithm of the hyperbolic cosine of the prediction error.

`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.
Parameters
IndexedSlices y_true
tensor of true targets.
IGraphNodeBase y_pred
tensor of predicted targets.
Returns
Tensor
Tensor with one scalar loss entry per sample.

Tensor logcosh(ValueTuple<PythonClassContainer, PythonClassContainer> y_true, IGraphNodeBase y_pred)

Logarithm of the hyperbolic cosine of the prediction error.

`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.
Parameters
ValueTuple<PythonClassContainer, PythonClassContainer> y_true
tensor of true targets.
IGraphNodeBase y_pred
tensor of predicted targets.
Returns
Tensor
Tensor with one scalar loss entry per sample.

object logcosh_dyn(object y_true, object y_pred)

Logarithm of the hyperbolic cosine of the prediction error.

`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.
Parameters
object y_true
tensor of true targets.
object y_pred
tensor of predicted targets.
Returns
object
Tensor with one scalar loss entry per sample.

Tensor MAE(IGraphNodeBase y_true, IGraphNodeBase y_pred)

Tensor MAE(IGraphNodeBase y_true, IEnumerable<IGraphNodeBase> y_pred)

object MAE_dyn(object y_true, object y_pred)

object MAPE(IGraphNodeBase y_true, IGraphNodeBase y_pred)

object MAPE_dyn(object y_true, object y_pred)

Tensor MSE(ndarray y_true, IEnumerable<IGraphNodeBase> y_pred)

Tensor MSE(IGraphNodeBase y_true, IGraphNodeBase y_pred)

Tensor MSE(IGraphNodeBase y_true, IEnumerable<IGraphNodeBase> y_pred)

Tensor MSE(IEnumerable<IGraphNodeBase> y_true, IGraphNodeBase y_pred)

Tensor MSE(IEnumerable<IGraphNodeBase> y_true, IEnumerable<IGraphNodeBase> y_pred)

Tensor MSE(ndarray y_true, IGraphNodeBase y_pred)

object MSE_dyn(object y_true, object y_pred)

Tensor MSLE(IGraphNodeBase y_true, IGraphNodeBase y_pred)

object MSLE_dyn(object y_true, object y_pred)

Tensor poisson(IGraphNodeBase y_true, IGraphNodeBase y_pred)

Computes the Poisson loss between y_true and y_pred.

The Poisson loss is the mean of the elements of the `Tensor` `y_pred - y_true * log(y_pred)`.

Usage:
Parameters
IGraphNodeBase y_true
Tensor of true targets.
IGraphNodeBase y_pred
Tensor of predicted targets.
Returns
Tensor
A `Tensor` with the mean Poisson loss.
Show Example
loss = tf.keras.losses.poisson([1.4, 9.3, 2.2], [4.3, 8.2, 12.2])
            print('Loss: ', loss.numpy())  # Loss: -0.8045559 

object poisson_dyn(object y_true, object y_pred)

Computes the Poisson loss between y_true and y_pred.

The Poisson loss is the mean of the elements of the `Tensor` `y_pred - y_true * log(y_pred)`.

Usage:
Parameters
object y_true
Tensor of true targets.
object y_pred
Tensor of predicted targets.
Returns
object
A `Tensor` with the mean Poisson loss.
Show Example
loss = tf.keras.losses.poisson([1.4, 9.3, 2.2], [4.3, 8.2, 12.2])
            print('Loss: ', loss.numpy())  # Loss: -0.8045559 

object serialize(IGraphNodeBase loss)

Tensor squared_hinge(IGraphNodeBase y_true, IGraphNodeBase y_pred)

Computes the squared hinge loss between `y_true` and `y_pred`.
Parameters
IGraphNodeBase 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.
IGraphNodeBase y_pred
The predicted values.
Returns
Tensor
Tensor with one scalar loss entry per sample.

object squared_hinge_dyn(object y_true, object y_pred)

Computes the squared hinge loss between `y_true` and `y_pred`.
Parameters
object 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.
object y_pred
The predicted values.
Returns
object
Tensor with one scalar loss entry per sample.

Public properties

PythonFunctionContainer binary_crossentropy_fn get;

PythonFunctionContainer categorical_crossentropy_fn get;

PythonFunctionContainer categorical_hinge_fn get;

PythonFunctionContainer cosine_fn get;

PythonFunctionContainer deserialize_fn get;

PythonFunctionContainer hinge_fn get;

PythonFunctionContainer logcosh_fn get;

PythonFunctionContainer poisson_fn get;

PythonFunctionContainer serialize_fn get;

PythonFunctionContainer sparse_categorical_crossentropy_fn get;

PythonFunctionContainer squared_hinge_fn get;