Training & Data
Guardrails & Training Reference
Understand the protections NeuraLib applies to time-series data, then choose activations, objectives, metrics, optimizers, and schedules that match your task.
Updated Publisher Alien_AlgorithmsPine Script v6
Built-in data guardrails
- Invalid rows are rejected: wrong-width rows and rows containing
nanever enter a dataset. - Shape checks protect calls: forward, training, backward, and evaluation paths validate tensors before graph execution.
- Train and validation remain separated: holdout extraction is chronological.
- Scaler leakage is controlled: validation transforms use the training-side profile.
- Rolling windows preserve time order: chronological reads remain correct even after ring-buffer wrapping.
Guardrails catch mechanics, not research assumptions
NeuraLib can reject a malformed row, but it cannot know that your feature definition contains future information or that your chosen target is economically meaningless.Activations
nl.ActivationKind includes Linear, ReLU, Leaky ReLU, ELU, GELU Approx, Sigmoid, Tanh, Softplus, Swish, and Softmax.
| Family | Typical role |
|---|---|
| Linear | Regression output or raw logits. |
| ReLU / Leaky ReLU / ELU | Efficient hidden-layer nonlinearities. |
| GELU Approx / Swish | Smooth nonlinearities for deeper or attention-style models. |
| Sigmoid | Binary probability output when the loss expects probabilities. |
| Tanh | Bounded signed hidden state or output. |
| Softmax | Multi-class probabilities; prefer a from-logits loss during training when available. |
Losses
| Loss | Typical use |
|---|---|
| MSE, MAE, Huber, LogCosh | General regression. Huber and LogCosh reduce sensitivity to large outliers. |
| Binary Cross Entropy | Two-class probability output. |
| Binary Cross Entropy From Logits | Numerically stable two-class raw-logit training. |
| Categorical Cross Entropy | Multi-class probability output. |
| Softmax Cross Entropy From Logits | Numerically stable multi-class raw-logit training. |
| Directional | Finance-oriented penalty for incorrect sign. |
| Quantile | A chosen conditional quantile instead of the mean. |
| Multi-Horizon Weighted | Multiple forecast horizons with explicit weights. |
| Sharpe | Sharpe-style risk-adjusted objective. |
Metrics
Metrics describe behavior without driving gradients. Available kinds include MAE, RMSE, Directional Accuracy, Binary Accuracy, Binary Accuracy From Logits, Categorical Accuracy, and Cosine Similarity.
Optimizers and schedules
Optimizers
sgd(), momentum(), rmsprop(), adam(), and adamW() cover simple through adaptive update rules.
Schedules
constantSchedule(), stepDecay(), cosineDecay(), and warmupCosine() control the current rate, which can be inspected with currentRate().
Choosing an objective
- Match output activation and loss expectations: logits with from-logits losses, probabilities with probability losses.
- Use robust regression losses when rare market moves dominate MSE.
- Keep a human-readable metric alongside the training objective.
- Compare against a simple baseline; lower loss is not automatically useful trading information.