sega_learn.neural_networks.loss

 
Modules
       
numpy

 
Classes
       
builtins.object
BCEWithLogitsLoss
CrossEntropyLoss
HuberLoss
MeanAbsoluteErrorLoss
MeanSquaredErrorLoss

 
class BCEWithLogitsLoss(builtins.object)
    Custom binary cross entropy loss with logits implementation using numpy.
 
Formula: -mean(y * log(p) + (1 - y) * log(1 - p))
 
Methods:
    __call__(self, logits, targets): Calculate the binary cross entropy loss.
 
  Methods defined here:
__call__(self, logits, targets)
Calculate the binary cross entropy loss.
 
Args:
    logits (np.ndarray): The logits (predicted values) of shape (num_samples,).
    targets (np.ndarray): The target labels of shape (num_samples,).
 
Returns:
    float: The binary cross entropy loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class CrossEntropyLoss(builtins.object)
    Custom cross entropy loss implementation using numpy for multi-class classification.
 
Formula: -sum(y * log(p) + (1 - y) * log(1 - p)) / m
Methods:
    __call__(self, logits, targets): Calculate the cross entropy loss.
 
  Methods defined here:
__call__(self, logits, targets)
Calculate the cross entropy loss.
 
Args:
    logits (np.ndarray): The logits (predicted values) of shape (num_samples, num_classes).
    targets (np.ndarray): The target labels of shape (num_samples,).
 
Returns:
    float: The cross entropy loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class HuberLoss(builtins.object)
    Custom Huber loss implementation using numpy.
 
Formula: mean(0.5 * (y_true - y_pred)**2) if abs(y_true - y_pred) <= delta else mean(delta * (abs(y_true - y_pred) - delta / 2))
 
Methods:
    __call__(self, y_true, y_pred, delta=1.0): Calculate the Huber loss.
 
  Methods defined here:
__call__(self, y_true, y_pred, delta=1.0)
Calculate the Huber loss.
 
Args:
    y_true (np.ndarray): The true labels of shape (num_samples,).
    y_pred (np.ndarray): The predicted values of shape (num_samples,).
    delta (float): The threshold for the Huber loss.
 
Returns:
    float: The Huber loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class MeanAbsoluteErrorLoss(builtins.object)
    Custom mean absolute error loss implementation using numpy.
 
Formula: mean(abs(y_true - y_pred))
 
Methods:
    __call__(self, y_true, y_pred): Calculate the mean absolute error loss.
 
  Methods defined here:
__call__(self, y_true, y_pred)
Calculate the mean absolute error loss.
 
Args:
    y_true (np.ndarray): The true labels of shape (num_samples,).
    y_pred (np.ndarray): The predicted values of shape (num_samples,).
 
Returns:
    float: The mean absolute error loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object

 
class MeanSquaredErrorLoss(builtins.object)
    Custom mean squared error loss implementation using numpy.
 
Formula: mean((y_true - y_pred) ** 2)
 
Methods:
    __call__(self, y_true, y_pred): Calculate the mean squared error loss.
 
  Methods defined here:
__call__(self, y_true, y_pred)
Calculate the mean squared error loss.
 
Args:
    y_true (np.ndarray): The true labels of shape (num_samples,).
    y_pred (np.ndarray): The predicted values of shape (num_samples,).
 
Returns:
    float: The mean squared error loss.

Data descriptors defined here:
__dict__
dictionary for instance variables
__weakref__
list of weak references to the object