tenzr::nn¶
Classes¶
| Name | |
|---|---|
| class | tenzr::nn::BatchNorm Batch normalization module over the channel dimension. |
| class | tenzr::nn::BCELoss Callable wrapper around the binary cross-entropy loss. |
| class | tenzr::nn::Conv2D 2-D convolution module with configurable kernel, stride, and padding. |
| class | tenzr::nn::CrossEntropyLoss Callable wrapper around the cross-entropy loss over logits. |
| class | tenzr::nn::Dropout Dropout regularization module active only in training mode. |
| class | tenzr::nn::Embedding Lookup-table module mapping integer indices to dense vectors. |
| class | tenzr::nn::GELU Gaussian error linear unit activation module. |
| class | tenzr::nn::LayerNorm Layer normalization module over the last dimension. |
| class | tenzr::nn::Linear Fully connected affine module applying a weight and optional bias. |
| class | tenzr::nn::LogSoftmax Log-softmax module normalizing over a configurable axis. |
| class | tenzr::nn::Module Base class for neural-network layers holding parameters, submodules, and training state. |
| class | tenzr::nn::MSELoss |
| class | tenzr::nn::ReLU Rectified linear unit activation module. |
| class | tenzr::nn::RMSNorm Root-mean-square normalization module. |
| class | tenzr::nn::Sequential Container module that applies its layers in order. |
| class | tenzr::nn::Sigmoid Logistic sigmoid activation module. |
| class | tenzr::nn::SiLU SiLU (swish) activation module. |
| class | tenzr::nn::Softmax Softmax module normalizing over a configurable axis. |
| class | tenzr::nn::Tanh Hyperbolic tangent activation module. |
Functions¶
| Name | |
|---|---|
| Array | softmax(const Array & input, int64_t axis =-1) |
| Array | log_softmax(const Array & input, int64_t axis =-1) |
| Tensor | MseLoss(const Tensor & pred, const Tensor & target, std::string reduction ="mean") |
| Tensor | BceLoss(const Tensor & pred, const Tensor & target, double eps =1.0e-7, std::string reduction ="mean") |
| Tensor | cross_entropy_loss(const Tensor & logits, const Tensor & targets, double eps =1.0e-7, std::string reduction ="mean") |
Functions Documentation¶
function softmax¶
Parameters:
- input Input tensor.
- axis Axis to normalize over.
- input Input tensor.
- axis Reduction axis, supporting negative indices.
Return:
- Softmax probabilities.
- Softmax-normalized tensor.
Numerically stable softmax along axis. Numerically stable softmax along axis.
function log_softmax¶
Parameters:
- input Input tensor.
- axis Axis to normalize over.
- input Input tensor.
- axis Reduction axis, supporting negative indices.
Return:
- Log-softmax values.
- Log-softmax tensor.
Numerically stable log-softmax along axis. Numerically stable log-softmax along axis.
function MseLoss¶
Parameters:
- pred Predictions.
- target Ground-truth values.
- reduction "mean", "sum", or "none".
- pred Predicted tensor.
- target Reference tensor with the same shape.
- reduction One of "mean", "sum", or "none".
Return:
- Scalar (or unreduced) loss.
- Scalar loss, or the elementwise squared error when reduction == "none".
Mean squared error between pred and target. Mean squared error between pred and target.
function BceLoss¶
Tensor BceLoss(
const Tensor & pred,
const Tensor & target,
double eps =1.0e-7,
std::string reduction ="mean"
)
Parameters:
- pred Predicted probabilities.
- target Binary ground-truth values.
- eps Clamp epsilon guarding log(0).
- reduction "mean", "sum", or "none".
- pred Predicted probabilities in [0, 1].
- target Reference labels with the same shape.
- eps Clamp bound keeping logarithms finite.
- reduction One of "mean", "sum", or "none".
Return:
- Scalar (or unreduced) loss.
- Scalar loss, or the elementwise loss when reduction == "none".
Binary cross-entropy between probabilities pred and targets in [0, 1]. Binary cross-entropy between probabilities pred and targets target.
function cross_entropy_loss¶
Tensor cross_entropy_loss(
const Tensor & logits,
const Tensor & targets,
double eps =1.0e-7,
std::string reduction ="mean"
)
Parameters:
- logits Unnormalized scores of shape (..., num_classes).
- targets Integer class indices.
- eps Clamp epsilon for the log-softmax.
- reduction "mean", "sum", or "none".
- logits Unnormalized scores of shape [B, C].
- targets Class indices [B] or one-hot probabilities [B, C].
- eps Unused; kept for interface symmetry.
- reduction One of "mean", "sum", or "none".
Return:
- Scalar (or unreduced) loss.
- Scalar loss, or the per-sample loss when reduction == "none".
Cross-entropy between unnormalized logits and integer class targets. Softmax cross-entropy from rank-2 logits.