Feyn Documentation

Feyn Documentation

  • Learn
  • Guides
  • Tutorials
  • API Reference
  • FAQ

›Feyn

Changelog

  • Feyn Changelog

Feyn

  • feyn
  • feyn.datasets
  • feyn.filters
  • feyn.inference
  • feyn.insights
  • feyn.losses
  • feyn.metrics
  • feyn.reference
  • feyn.tools
  • feyn.plots
  • feyn.plots.interactive

feyn.losses

A collection of loss functions for use with feyn.

The loss funtions can be specified as arguments to the `feyn.fit_models` method. A good choice of loss function can sometimes speed up the training. For most uses the default loss function, `squared_error` is a fine choice.

Note: Data scientist with experience from other frameworks may be used to thinking that the loss function is very significant. In practice it matters less in QLattices, for reasons that have to do with the large range of initial parameters for models.

function absolute_error

def absolute_error(
    y_true: numpy.ndarray,
    y_pred: numpy.ndarray
) -> numpy.ndarray
Compute the absolute error loss.

Arguments:
    y_true -- Ground truth (correct) values.
    y_pred -- Predicted values.

Returns:
    nd.array -- The losses as an array of floats.

function binary_cross_entropy

def binary_cross_entropy(
    y_true: numpy.ndarray,
    y_pred: numpy.ndarray
) -> numpy.ndarray
Compute the cross entropy loss between the labels and predictions.

This is a good alternative choice for binary classification problems. If cannot be used for fitting models with output data that is not binary. Doing so will result in a RuntimeError.

Arguments:
    y_true -- Ground truth (correct) values.
    y_pred -- Predicted values.

Returns:
    nd.array -- The losses as an array of floats.

function categorical_cross_entropy

def categorical_cross_entropy(
    y_true: numpy.ndarray,
    y_pred: numpy.ndarray
) -> numpy.ndarray
Compute the cross entropy loss between the labels and predictions.

This is a good alternative choice for binary classification problems. If cannot be used for fitting models with output data that is not binary. Doing so will result in a RuntimeError.

Arguments:
    y_true -- Ground truth (correct) values.
    y_pred -- Predicted values.

Returns:
    nd.array -- The losses as an array of floats.

function squared_error

def squared_error(
    y_true: numpy.ndarray,
    y_pred: numpy.ndarray
) -> numpy.ndarray
Compute the squared error loss.

This is the default loss function used in fitting and sampling models from the QLattice.

Arguments:
    y_true -- Ground truth (correct) values.
    y_pred -- Predicted values.

Returns:
    nd.array -- The losses as an array of floats.
← feyn.insightsfeyn.metrics →
  • function absolute_error
  • function binary_cross_entropy
  • function categorical_cross_entropy
  • function squared_error

Subscribe to get news about Feyn and the QLattice.

You can opt out at any time, and you can read our privacy policy here.

Copyright © 2024 Abzu.ai - Feyn license: CC BY-NC-ND 4.0
Feyn®, QGraph®, and the QLattice® are registered trademarks of Abzu®