Skip to content

Linear Derivative

Functions

linear_derivative(Z)

Compute the derivative of the linear activation function.

Parameters:

Name Type Description Default
Z ndarray

The input array.

required

Returns:

Type Description

numpy.ndarray: An array of ones with the same shape as Z.

Example
Z = np.array([[1, 2], [3, 4]])
dZ = linear_derivative(Z)
print(dZ)
Source code in microkeras/activations/linear_derivative.py
def linear_derivative(Z):
    """
    Compute the derivative of the linear activation function.

    Args:
        Z (numpy.ndarray): The input array.

    Returns:
        numpy.ndarray: An array of ones with the same shape as Z.

    Example:
        ```python
        Z = np.array([[1, 2], [3, 4]])
        dZ = linear_derivative(Z)
        print(dZ)
        ```
    """
    return np.ones_like(Z)