Softmax#

class vulkpy.nn.Softmax#

Bases: Module

SoftMax

Methods Summary

__call__(x)

Call Module

backward(dy)

Backward

forward(x)

Forward

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

Parameters:

dy (vulkpy.Array) – Batch grad

Returns:

Batch grad

Return type:

vulkpy.Array

Notes

\[dx = dy \cdot y(1 - y)\]
forward(x: Array) Array#

Forward

Parameters:

x (vulkpy.Array) – Batch input

Returns:

Batch output

Return type:

vulkpy.Array

Notes

\[y = \exp (x) / \sum _i \exp(x_i)\]

Warning

Generally, users should not call this method directly. Use __call__ instead, where input / output are stored for training.

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__()#