syna.functions.math module

class syna.functions.math.Abs[source]

Bases: Function

Elementwise absolute value with direct sign-based backward.

backward(gy)[source]
forward(x)[source]
class syna.functions.math.Add[source]

Bases: Function

Elementwise add with broadcasting support.

backward(gy: ndarray)[source]
forward(x0, x1)[source]
class syna.functions.math.Clip(x_min, x_max)[source]

Bases: Function

Clip values into [x_min, x_max].

backward(gy)[source]
forward(x)[source]
class syna.functions.math.Cos[source]

Bases: Function

cos(x)

backward(gy)[source]
forward(x)[source]
class syna.functions.math.Div[source]

Bases: Function

Elementwise division with broadcasting support.

backward(gy)[source]
forward(x0, x1)[source]
class syna.functions.math.Exp[source]

Bases: Function

Exponential function.

backward(gy)[source]
forward(x)[source]
class syna.functions.math.Linear[source]

Bases: Function

Linear layer y = x.dot(W) + b (b optional).

backward(gy)[source]
forward(x, W, b)[source]
class syna.functions.math.Log[source]

Bases: Function

Natural logarithm.

backward(gy)[source]
forward(x)[source]
class syna.functions.math.MatMul[source]

Bases: Function

Matrix multiplication x @ W.

Expects both x and W to be 2D arrays (matrices). Does not support batched or higher-dimensional tensor multiplication.

backward(gy)[source]
forward(x, W)[source]
class syna.functions.math.Max(axis=None, keepdims=False)[source]

Bases: Function

Max reduction with correct backward distribution.

backward(gy)[source]
forward(x)[source]
class syna.functions.math.Maximum[source]

Bases: Function

Elementwise maximum with direct backward using masks.

backward(gy)[source]
forward(x0, x1)[source]
class syna.functions.math.Min(axis=None, keepdims=False)[source]

Bases: Max

Min reduction re-uses Max implementation but calls np.min on forward.

forward(x)[source]
class syna.functions.math.Minimum[source]

Bases: Function

Elementwise minimum with direct backward using masks (faster than algebraic identity).

backward(gy)[source]
forward(x0, x1)[source]
class syna.functions.math.Mul[source]

Bases: Function

Elementwise multiply with broadcasting support.

backward(gy)[source]
forward(x0, x1)[source]
class syna.functions.math.Neg[source]

Bases: Function

Negation (unary -).

backward(gy)[source]
forward(x)[source]
class syna.functions.math.Pow(c: float)[source]

Bases: Function

Power operation x**c where c is a constant.

backward(gy)[source]
forward(x)[source]
class syna.functions.math.Sin[source]

Bases: Function

sin(x)

backward(gy)[source]
forward(x)[source]
class syna.functions.math.Sqrt[source]

Bases: Function

Elementwise sqrt with dedicated backward (faster than generic pow).

backward(gy)[source]
forward(x)[source]
class syna.functions.math.Sub[source]

Bases: Function

Elementwise subtraction with broadcasting support.

backward(gy)[source]
forward(x0, x1)[source]
class syna.functions.math.Tanh[source]

Bases: Function

Hyperbolic tangent.

backward(gy)[source]
forward(x)[source]
syna.functions.math.abs(x) Tensor[source]

Elementwise absolute value.

syna.functions.math.add(x0, x1) Tensor[source]

Add two tensors (supports broadcasting).

syna.functions.math.clip(x, x_min, x_max) Tensor[source]

Clip tensor values to [x_min, x_max].

syna.functions.math.cos(x) Tensor[source]

Cosine of x.

syna.functions.math.div(x0, x1) Tensor[source]

Divide x0 by x1 (supports broadcasting).

syna.functions.math.exp(x) Tensor[source]

Exponential of x (e**x).

syna.functions.math.linear(x, W, b=None) Tensor[source]

Linear transformation with optional bias.

syna.functions.math.linear_simple(x, W, b=None) Tensor[source]

A slightly optimized linear for common case: returns t + b when b is given.

syna.functions.math.log(x) Tensor[source]

Natural log of x.

syna.functions.math.matmul(x, W) Tensor[source]

Matrix multiply x @ W.

syna.functions.math.max(x, axis=None, keepdims=False)[source]

Max reduction wrapper.

syna.functions.math.maximum(x, y) Tensor[source]

Elementwise maximum using a dedicated Function for performance.

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

Mean like torch.mean: mean over all elements by default, or over given axis/axes.

syna.functions.math.min(x, axis=None, keepdims=False)[source]

Min reduction wrapper.

syna.functions.math.minimum(x, y) Tensor[source]

Elementwise minimum using a dedicated Function for performance.

syna.functions.math.mul(x0, x1) Tensor[source]

Elementwise multiply two tensors (supports broadcasting).

syna.functions.math.neg(x) Tensor[source]

Return -x.

syna.functions.math.pow(x, c) Tensor[source]

Raise x to the constant power c.

syna.functions.math.sin(x) Tensor[source]

Sine of x.

syna.functions.math.sqrt(x) Tensor[source]

Elementwise square root.

syna.functions.math.sub(x0, x1) Tensor[source]

Subtract x1 from x0 (supports broadcasting).

syna.functions.math.tanh(x)[source]