phitodeep.layers.activation

Classes

ReLu

Base class for all layers in the network.

LeakyReLu

Base class for all layers in the network.

GELU

Base class for all layers in the network.

Swish

Base class for all layers in the network.

Sigmoid

Base class for all layers in the network.

Tanh

Base class for all layers in the network.

Softmax

Base class for all layers in the network.

ELU

Base class for all layers in the network.

Module Contents

class phitodeep.layers.activation.ReLu[source]

Bases: phitodeep.layers.base.Layer

Base class for all layers in the network.

forward(X)[source]
backward(dL_dZ)[source]

Backpropagate through ReLU activation. ReLU derivative: 1 if X > 0, else 0

copy()[source]
class phitodeep.layers.activation.LeakyReLu(alpha=0.01)[source]

Bases: phitodeep.layers.base.Layer

Base class for all layers in the network.

alpha = 0.01
forward(X)[source]
backward(dL_dZ)[source]

Backward pass through the block.

Parameters:

dL_dZ – gradient of loss w.r.t. output of this block

Returns:

gradient of loss w.r.t. input (to pass to previous layer)

Return type:

dL_dX

copy()[source]
class phitodeep.layers.activation.GELU[source]

Bases: phitodeep.layers.base.Layer

Base class for all layers in the network.

constant = 0.044715
forward(X)[source]
backward(dL_dZ)[source]

Backward pass through the block.

Parameters:

dL_dZ – gradient of loss w.r.t. output of this block

Returns:

gradient of loss w.r.t. input (to pass to previous layer)

Return type:

dL_dX

copy()[source]
class phitodeep.layers.activation.Swish[source]

Bases: phitodeep.layers.base.Layer

Base class for all layers in the network.

forward(X)[source]
backward(dL_dZ)[source]

Backward pass through the block.

Parameters:

dL_dZ – gradient of loss w.r.t. output of this block

Returns:

gradient of loss w.r.t. input (to pass to previous layer)

Return type:

dL_dX

copy()[source]
class phitodeep.layers.activation.Sigmoid[source]

Bases: phitodeep.layers.base.Layer

Base class for all layers in the network.

forward(X)[source]
backward(dL_dZ)[source]

Backpropagate through Sigmoid activation. Sigmoid derivative: sigmoid(Z) * (1 - sigmoid(Z))

copy()[source]
class phitodeep.layers.activation.Tanh[source]

Bases: phitodeep.layers.base.Layer

Base class for all layers in the network.

forward(X)[source]
backward(dL_dZ)[source]

Backpropagate through Tanh activation. Tanh derivative: 1 - tanh(Z)^2

copy()[source]
class phitodeep.layers.activation.Softmax[source]

Bases: phitodeep.layers.base.Layer

Base class for all layers in the network.

forward(X)[source]
backward(dL_dZ)[source]

Backpropagate through Softmax activation. When paired with CategoricalCrossEntropy, the combined gradient (y_pred - one_hot(y_true)) / N is computed entirely in the loss, so this layer is a straight pass-through.

copy()[source]
class phitodeep.layers.activation.ELU(alpha=1.0)[source]

Bases: phitodeep.layers.base.Layer

Base class for all layers in the network.

alpha_activation = 1.0
forward(X)[source]
backward(dL_dZ)[source]

Backpropagate through ELU activation. ELU derivative: 1 if X > 0, else alpha * exp(X)

copy()[source]