Skip to content

Calculate Z Method

Functions

calculate_Z(W, A_prev, b)

Calculate the linear combination Z = W * A_prev + b.

Parameters:

Name Type Description Default
W ndarray

Weight matrix of the current layer.

required
A_prev ndarray

Activation output from the previous layer.

required
b ndarray

Bias vector of the current layer.

required

Returns:

Type Description

numpy.ndarray: The linear combination Z.

Example
W = np.random.randn(3, 4)
A_prev = np.random.randn(4, 5)
b = np.random.randn(3, 1)
Z = calculate_Z(W, A_prev, b)
print(Z.shape)
Source code in microkeras/operations/forward/calculate_Z.py
def calculate_Z(W, A_prev, b):
    """
    Calculate the linear combination Z = W * A_prev + b.

    Args:
        W (numpy.ndarray): Weight matrix of the current layer.
        A_prev (numpy.ndarray): Activation output from the previous layer.
        b (numpy.ndarray): Bias vector of the current layer.

    Returns:
        numpy.ndarray: The linear combination Z.

    Example:
        ```python
        W = np.random.randn(3, 4)
        A_prev = np.random.randn(4, 5)
        b = np.random.randn(3, 1)
        Z = calculate_Z(W, A_prev, b)
        print(Z.shape)
        ```
    """
    return np.dot(W, A_prev) + b