syna.functions.function module

class syna.functions.function.BroadcastTo(shape: Tuple[int, ...])[source]

Bases: Function

Broadcast x to shape.

backward(gy)[source]
forward(x)[source]
class syna.functions.function.GetItem(slices)[source]

Bases: Function

Supports x[slices] and produces gradient via GetItemGrad.

backward(gy)[source]
forward(x)[source]
class syna.functions.function.GetItemGrad(slices, in_shape)[source]

Bases: Function

Gradient for getitem: scatters gy back into the original shape.

forward(x)[source]
class syna.functions.function.Reshape(shape: Tuple[int, ...])[source]

Bases: Function

Reshape tensor to a given shape.

backward(gy)[source]
forward(x)[source]
class syna.functions.function.Sum(axis, keepdims)[source]

Bases: Function

Sum reduction, supports axis and keepdims.

backward(gy)[source]
forward(x)[source]
class syna.functions.function.SumTo(shape: Tuple[int, ...])[source]

Bases: Function

Sum elements to target shape (inverse of broadcast_to).

backward(gy)[source]
forward(x)[source]
class syna.functions.function.Transpose(axes=None)[source]

Bases: Function

Transpose with optional axes permutation.

backward(gy)[source]
forward(x)[source]
syna.functions.function.broadcast_to(x, shape: Tuple[int, ...]) Tensor[source]

Broadcast x to the given shape.

syna.functions.function.dropout(x, dropout_ratio=0.5) Tensor[source]

Dropout during training; identity during evaluation.

syna.functions.function.expand_dims(x, axis: int) Tensor[source]

Insert a dimension of size 1 at index axis.

syna.functions.function.flatten(x) Tensor[source]

Flatten all dimensions except the first (batch) dimension.

syna.functions.function.get_item(x, slices) Tensor[source]

Index into tensor with slices.

syna.functions.function.reshape(x, shape) Tensor[source]

Reshape tensor; if shape matches returns as_tensor(x).

syna.functions.function.sum(x, axis: Tuple[int, ...] | None = None, keepdims=False) Tensor[source]

Sum elements along given axes.

syna.functions.function.sum_to(x, shape: Tuple[int, ...]) Tensor[source]

Sum elements of x so result has shape.

syna.functions.function.transpose(x, axes=None) Tensor[source]

Transpose tensor along axes.