Caten Documentation

  • Home
  • Quickstart
  • Development
  • API Reference
    • caten/air
    • caten/aasm
    • caten/codegen
    • caten/api
      • Overview
      • Tensor
      • Func
      • Module
      • Model
      • Initializers
      • ShapeTracker
      • Facet API
      • StateDict
    • caten/nn
      • Activation
      • Convolution
      • Criterion
      • Embedding
      • Linear
      • Normalization
      • Padding
      • Pooling
      • Encoding
      • Optimizers
  • Ready to use packages
    • Overview
    • caten/apps.gpt2
  • External Packages
    • caten/gguf
    • caten/oonx
    • caten/llm
In this article
  • Criterion
    • [class] L1NormLoss
    • [function] !l1norm
    • [class] MSELoss
    • [function] !mse
    • [class] CrossEntropyLoss
    • [function] !cross-entropy

Criterion

  1. Caten Documentation
  2. API Reference
  3. caten/nn
  4. Criterion
|
  • Share via

  •  Edit this article

Criterion

[class] L1NormLoss

(L1NormLoss &key (reduction :mean))

Implements L1Norm Loss:

l(x, y) = L = {l_1, ..., l_n}^\intercal, l_n = abs(x_n - y_n)

reduction is one of :mean or :sum.

[function] !l1norm

(!l1norm a b &key (reduction :mean))

Computes L1Norm

[class] MSELoss

(MSELoss &key (reduction :mean))

Implements MSE Loss:

l(x, y) = L = {l_1, ..., l_n}^\intercal, l_n = (x_n - y_n)^2

reduction is one of :mean or :sum.

[function] !mse

(!mse a b &key (reduction :mean))

Computes MSE Loss between a and b.

[class] CrossEntropyLoss

(CrossEntropyLoss &key (reduction :mean) (delta 1e-5))

Returns a tensor that measures the Cross-Entropy-Error between each element in the x and labels. labels are one-hot encoded.

L_i = -p_ilog(x_i + delta)
\begin{equation}
  out_i=
  \begin{cases}
    sum(L)  & \text{reduction = sum} \\
    mean(L) & \text{reduction = mean} \\
    L       & \text{otherwise}
  \end{cases}
\end{equation}

[function] !cross-entropy

(!cross-entropy x labels &key (reduction :mean) (delta 1e-5))
Computes Cross Entropy Loss between x and labels. labels are one-hot encoded.

Search
Enter a keyword to search.