viva_tensor/nn

Types

Linear Layer (Fully Connected) y = x @ W.T + b

pub type Linear {
  Linear(w: autograd.Variable, b: autograd.Variable)
}

Constructors

Values

pub fn linear(
  tape: autograd.Tape,
  in_features: Int,
  out_features: Int,
) -> autograd.Traced(Linear)

Initializes a new Linear layer

pub fn linear_forward(
  tape: autograd.Tape,
  layer: Linear,
  x: autograd.Variable,
) -> Result(
  autograd.Traced(autograd.Variable),
  tensor.TensorError,
)

Forward pass of the Linear layer

pub fn mse_loss(
  tape: autograd.Tape,
  pred: autograd.Variable,
  target: autograd.Variable,
) -> Result(
  autograd.Traced(autograd.Variable),
  tensor.TensorError,
)

Loss function: Mean Squared Error (MSE) L = mean((pred - target)^2)

pub fn relu(
  tape: autograd.Tape,
  x: autograd.Variable,
) -> autograd.Traced(autograd.Variable)

ReLU activation function

Search Document