Module#

class vulkpy.nn.Module#

Bases: object

Abstract base class for Module

See also

vulkpy.nn.Dense

Dense Layer (subclass)

vulkpy.nn.ReLU

ReLU Layer (subclass)

vulkpy.nn.Sigmoid

Sigmoid Layer (subclass)

vulkpy.nn.Softmax

Softmax Layer (subclass)

vulkpy.nn.Sequence

Sequential Model

Notes

Module is designed to for Neural Network Layer.

Subclass must implement forward() and backward(), and can implement zero_grad() and update() when it is necessary.

Methods Summary

__call__(x)

Call Module

backward(dy)

Backward Calculation

forward(x)

Forward Calculation

update()

Update parameters based on accumulated gradients

zero_grad()

Reset accumulated gradients to 0.

Methods Documentation

__call__(x: Array) Array#

Call Module

Parameters:

x (vulkpy.Array) – Input

Returns:

y – Output

Return type:

vulkpy.Array

Raises:

ValueError – If input (x) shape doesn’t have at least 2-dimensions.

Notes

This function stores input (x) and output (y) for training.

backward(dy: Array) Array#

Backward Calculation

Parameters:

dy (vulkpy.Array) – dL/dy propagated from following layer

Returns:

dx – dL/dx propagated to previous layer

Return type:

vulkpy.Array

Notes

Subclass must implement this method.

forward(x: Array) Array#

Forward Calculation

Parameters:

x (vulkpy.Array) – Input features

Returns:

y – Output

Return type:

vulkpy.Array

Notes

Subclass must implement this method.

update()#

Update parameters based on accumulated gradients

Notes

Base class implement no-operation. Subclass can customize this method.

zero_grad()#

Reset accumulated gradients to 0.

Notes

Base class implement no-operation. Subclass can customize this method.

__init__()#