CosineSimilarity

public class CosineSimilarity

A metric that computes the cosine similarity metric between labels and predictions.

Constants

int DEFAULT_AXIS

Inherited Constants

Public Constructors

CosineSimilarity (Ops tf, String name, long seed, Class<T> type)
Creates a metric that computes the cosine similarity metric between labels and predictions with a default axis, DEFAULT_AXIS
CosineSimilarity (Ops tf, String name, int axis, long seed, Class<T> type)
Creates a metric that computes the cosine similarity metric between labels and predictions.
CosineSimilarity (Ops tf, String name, int[] axis, long seed, Class<T> type)
Creates a CosineSimilarity metric

Public Methods

Operand <T>
call ( Operand <? extends TNumber > labels, Operand <? extends TNumber > predictions)
Calculates the weighted loss between labels and predictions

Inherited Methods

Constants

public static final int DEFAULT_AXIS

Constant Value: -1

Public Constructors

public CosineSimilarity (Ops tf, String name, long seed, Class<T> type)

Creates a metric that computes the cosine similarity metric between labels and predictions with a default axis, DEFAULT_AXIS

Parameters
tf the TensorFlow Ops
name the name of this metric, if null then metric name is getSimpleName() .
seed the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.
type the type for the variables and result

public CosineSimilarity (Ops tf, String name, int axis, long seed, Class<T> type)

Creates a metric that computes the cosine similarity metric between labels and predictions.

Parameters
tf the TensorFlow Ops
name the name of this metric, if null then metric name is getSimpleName() .
axis The dimension along which the cosine similarity is computed.
seed the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.
type the type for the variables and result

public CosineSimilarity (Ops tf, String name, int[] axis, long seed, Class<T> type)

Creates a CosineSimilarity metric

Parameters
tf the TensorFlow Ops
name the name of this metric, if null then metric name is getSimpleName() .
axis The dimension along which the cosine similarity is computed.
seed the seed for random number generation. An initializer created with a given seed will always produce the same random tensor for a given shape and data type.
type the type for the variables and result

Public Methods

public Operand <T> call ( Operand <? extends TNumber > labels, Operand <? extends TNumber > predictions)

Calculates the weighted loss between labels and predictions

Parameters
labels the truth values or labels
predictions the predictions
Returns
  • the loss