Skip to content

SGD Class

Stochastic Gradient Descent (SGD) optimizer.

This class implements the SGD optimization algorithm.

Attributes:

Name Type Description
learning_rate float

The learning rate for parameter updates.

Methods:

Name Description
minimize_wrapper

A method to perform training over multiple epochs.

Example
optimizer = SGD(learning_rate=0.01)
history = optimizer.minimize_wrapper(model, X_train, Y_train, 'categorical_crossentropy', 32, 10, ['accuracy'])
Source code in microkeras/optimizers/sgd.py
class SGD:
    """
    Stochastic Gradient Descent (SGD) optimizer.

    This class implements the SGD optimization algorithm.

    Attributes:
        learning_rate (float): The learning rate for parameter updates.

    Methods:
        minimize_wrapper: A method to perform training over multiple epochs.

    Example:
        ```python
        optimizer = SGD(learning_rate=0.01)
        history = optimizer.minimize_wrapper(model, X_train, Y_train, 'categorical_crossentropy', 32, 10, ['accuracy'])
        ```
    """
    def __init__(self, learning_rate=0.01):
        """
        Initialize the SGD optimizer.

        Args:
            learning_rate (float): The learning rate to use for parameter updates. Default is 0.01.
        """
        self.learning_rate = learning_rate
        self.learning_rate = learning_rate

    minimize_wrapper = minimize_wrapper

Functions

__init__(learning_rate=0.01)

Initialize the SGD optimizer.

Parameters:

Name Type Description Default
learning_rate float

The learning rate to use for parameter updates. Default is 0.01.

0.01
Source code in microkeras/optimizers/sgd.py
def __init__(self, learning_rate=0.01):
    """
    Initialize the SGD optimizer.

    Args:
        learning_rate (float): The learning rate to use for parameter updates. Default is 0.01.
    """
    self.learning_rate = learning_rate
    self.learning_rate = learning_rate