brainmass.objectives.cosine_sim

Contents

brainmass.objectives.cosine_sim#

brainmass.objectives.cosine_sim(as_loss=False, epsilon=0.0)[source]#

Build a cosine-similarity score between two (flattened) time series.

Thin wrapper over braintools.metric.cosine_similarity(); the inputs are flattened to a single vector so the result is a scalar.

Parameters:
  • as_loss (bool, default False) – If True, return 1 - cos (to minimise); otherwise the raw cosine similarity (to maximise).

  • epsilon (float, default 0.0) – Numerical floor forwarded to braintools.metric.cosine_similarity().

Returns:

score(prediction, target) -> scalar.

Return type:

callable