OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
opennn Namespace Reference

Classes

struct  ActivationOp
 Element-wise non-linear activation (Identity, Sigmoid, Tanh, ReLU, Softmax). More...
 
class  AdaptiveMomentEstimation
 Adam optimizer with first/second gradient moments for stochastic minibatch training. More...
 
class  Addition
 Element-wise addition layer that sums two input tensors of identical shape (residual connections). More...
 
struct  AddOp
 Element-wise sum of several input tensors (used by residual connections). More...
 
class  ApproximationNetwork
 Factory neural network preconfigured for regression / function approximation. More...
 
struct  AttentionOp
 Scaled dot-product attention with optional causal mask and dropout. More...
 
struct  AugmentationSettings
 Image augmentation parameters: reflections, rotations and translations applied at training. More...
 
class  AutoAssociationNetwork
 Factory neural network preconfigured for auto-association (anomaly detection). More...
 
class  Backend
 Process-wide singleton that owns the thread pool and the cuBLAS/cuDNN handles. More...
 
struct  BackPropagation
 Workspace holding parameter gradients and per-layer deltas during a backward pass. More...
 
struct  BackPropagationLM
 Backprop scratch state specific to Levenberg-Marquardt (per-sample errors, Jacobian, Hessian approx). More...
 
struct  Batch
 Minibatch container holding pinned host/device buffers and views into a Dataset. More...
 
struct  BatchNormOp
 Batch normalization with learnable scale/shift and running statistics for inference. More...
 
class  Bounding
 Output bounding layer that clips outputs to configured lower and upper limits. More...
 
struct  BoundOp
 Clamps each output channel to a configurable lower/upper interval. More...
 
struct  BoxPlot
 Five-number summary (minimum, Q1, median, Q3, maximum) used to draw a box plot. More...
 
struct  Buffer
 Owning raw byte buffer that lives on CPU or CUDA memory, with aligned (re)allocation. More...
 
class  ClassificationNetwork
 Factory neural network preconfigured for tabular classification. More...
 
struct  CombinationOp
 Affine combination output = input * weights + bias (the dense matmul building block). More...
 
struct  CombinationReluOp
 Fused affine + ReLU activation (uses cuBLASLt epilogue on GPU when available). More...
 
class  Configuration
 Global singleton holding the OpenNN device and precision configuration. More...
 
class  Convolutional
 2D convolutional layer with kernel, stride, padding, activation, and optional batch normalization. More...
 
class  ConvolutionalRelu
 Fused convolution + ReLU layer; runs as a single GPU op (cudnn) and is CUDA-Graph friendly. More...
 
struct  ConvolutionOp
 2D convolution operator (NHWC layout) backed by Eigen on CPU and cuDNN on GPU. More...
 
struct  ConvolutionReluOp
 Fused 2D convolution + ReLU activation (uses cuDNN fused epilogue on GPU). More...
 
struct  Correlation
 Result of a correlation analysis: model parameters, fit quality, and the method/form used. More...
 
class  CsvReader
 Tokenising CSV reader that returns string_views into a single backing buffer. More...
 
class  Dataset
 Abstract base class for OpenNN datasets, owning samples, variables, and metadata. More...
 
class  Dense
 Fully-connected layer with configurable activation, optional batch normalization and dropout. More...
 
class  DenseRelu
 Fused dense + ReLU layer; combines linear projection and ReLU activation in a single op for performance. More...
 
struct  Descriptives
 Summary statistics (minimum, maximum, mean, standard deviation) for one variable. More...
 
struct  DropoutOp
 Inverted dropout: at training time zeros activations with probability rate and rescales survivors. More...
 
class  Embedding
 Token-id to dense vector embedding layer with optional scaling and positional encoding. More...
 
struct  EmbeddingLookupOp
 Token embedding lookup with optional scaling and additive positional encoding. More...
 
struct  EnumMap
 
class  FileReader
 Thread-safe positional file reader (pread on POSIX, overlapped ReadFile on Windows). More...
 
class  FileWriter
 Streaming writer that finalises by atomic-renaming a .tmp file to its final path. More...
 
struct  FlatOp
 Flattens a multi-dimensional tensor into a 2D (batch, features) tensor. More...
 
class  Flatten
 Flatten layer that reshapes a multi-dimensional input into a single 1D feature vector. More...
 
class  ForecastingNetwork
 Factory neural network preconfigured for time-series forecasting. More...
 
struct  ForwardPropagation
 Workspace holding the activations of every layer during a forward pass. More...
 
class  GeneticAlgorithm
 Selects the optimal subset of input features using an evolutionary genetic algorithm. More...
 
class  GrowingInputs
 Selects the optimal subset of input features by greedily growing the input set. More...
 
class  GrowingNeurons
 Selects the optimal hidden neuron count by incrementally growing the number of neurons. More...
 
struct  Histogram
 Frequency histogram with per-bin minimums, maximums, centers, and counts. More...
 
class  ImageClassificationNetwork
 Factory convolutional neural network preconfigured for image classification. More...
 
class  ImageDataset
 Image dataset that streams BMP images from disk with optional augmentation. More...
 
class  InputsSelection
 Abstract base class for algorithms that search the optimal subset of input variables. More...
 
struct  InputsSelectionResults
 Aggregated results of an inputs selection run including optimal inputs and error histories. More...
 
class  Json
 
class  JsonDocument
 
class  JsonWriter
 
class  KMeans
 K-means clustering utility that partitions samples into the requested number of clusters. More...
 
class  LanguageDataset
 Token-based language dataset with input/target vocabularies and binary token cache. More...
 
class  Layer
 Abstract base class for all OpenNN layers; orchestrates operators and shape propagation. More...
 
struct  LayerNormOp
 Layer normalization with learnable scale/shift, applied across the embedding dimension. More...
 
class  LevenbergMarquardtAlgorithm
 Levenberg-Marquardt optimizer combining Gauss-Newton and gradient descent through an adaptive damping factor. More...
 
class  Loss
 Unified loss container supporting MSE, cross-entropy, Minkowski, weighted, and regularized variants. More...
 
struct  MergeOp
 Reshapes (batch, heads, seq, head_dim) tensors back into (batch, seq, embed); no parameters. More...
 
class  ModelExpression
 Emits a trained neural network as source code in C, Python, JavaScript, or PHP. More...
 
class  ModelSelection
 Orchestrates model selection by combining inputs selection and neurons selection over a TrainingStrategy. More...
 
class  MultiHeadAttention
 Multi-head scaled dot-product attention layer used in transformer architectures. More...
 
struct  MultiHeadProjectionOp
 Projects (input_features) into (heads * head_dim) and reshapes for multi-head attention. More...
 
class  NeuralNetwork
 Container of layers forming a feed-forward neural network, with parameter storage and I/O. More...
 
class  NeuronSelection
 Abstract base class for algorithms that select the optimal number of hidden neurons. More...
 
struct  NeuronsSelectionResults
 Aggregated results of a neurons selection run including the optimal neuron count and error histories. More...
 
class  Normalization3d
 Layer normalization over the embedding axis of a 3D (batch, sequence, embedding) tensor. More...
 
struct  Operator
 Base class for compute building blocks composed by layers (matmul, activation, dropout, etc.). More...
 
class  Optimizer
 Abstract base class for training optimizers (Adam, SGD, Quasi-Newton, Levenberg-Marquardt). More...
 
struct  OptimizerData
 Per-optimizer scratch state (moments, directions, iteration counter) backing the update step. More...
 
struct  Pool3dOp
 Sequence-wide 1D pooling over the embedding dimension (mean or max). More...
 
class  Pooling
 2D spatial pooling layer supporting max and average reduction. More...
 
class  Pooling3d
 Sequence pooling layer reducing the time axis of a (sequence, features) input. More...
 
struct  PoolOp
 2D pooling operator supporting max and average reductions. More...
 
class  QuasiNewtonMethod
 Quasi-Newton optimizer using the BFGS inverse-Hessian approximation with line search. More...
 
class  Recurrent
 Basic recurrent (RNN) layer that unrolls over time steps with a shared activation. More...
 
class  Registry
 
class  ResponseOptimization
 Optimizes input values so that a network's outputs satisfy user-defined conditions and objectives. More...
 
struct  ScaleOp
 Scales inputs to a target range using per-feature minimum/maximum or mean/std statistics. More...
 
class  Scaling
 Input scaling layer that normalizes features using per-variable descriptive statistics. More...
 
class  ScopedTimer
 
struct  Shape
 Fixed-capacity small-vector describing tensor dimensions (rank up to MaxRank). More...
 
class  SimpleResNet
 Factory residual neural network with a configurable number of blocks per stage. More...
 
struct  Stats
 
class  StochasticGradientDescent
 Stochastic gradient descent with optional momentum, Nesterov, and learning-rate decay. More...
 
class  TabularDataset
 Tabular dataset with CSV loading, scaling, descriptive statistics and correlation analysis. More...
 
struct  TensorSpec
 Lightweight description of a tensor's shape and data type (no storage attached). More...
 
struct  TensorView
 Non-owning view over a tensor: pointer, shape, and data type with rich reshape helpers. More...
 
class  TestingAnalysis
 Performs post-training analysis of a neural network: errors, confusion matrices, ROC, gain charts, etc. More...
 
class  TextClassificationNetwork
 Factory neural network preconfigured for text classification. More...
 
class  ThreadSafeQueue
 
class  TimeSeriesDataset
 Time series dataset with configurable past/future windows and autocorrelation analysis. More...
 
struct  TrainingResults
 History and final metrics produced by a training run. More...
 
class  TrainingStrategy
 High-level orchestrator pairing a Loss with an Optimizer for a network/dataset. More...
 
class  Transformer
 Factory encoder-decoder Transformer neural network for sequence-to-sequence tasks. More...
 
class  TransformerDecoder
 Drives token-by-token inference of a Transformer model with configurable sampling strategies. More...
 
struct  TypeInfo
 Compile-time traits mapping an opennn::Type to its underlying numeric type and library identifiers. More...
 
struct  TypeInfo< Type::BF16 >
 TypeInfo specialization for bfloat16 (BF16) tensors. More...
 
struct  TypeInfo< Type::FP32 >
 TypeInfo specialization for 32-bit floating point (FP32) tensors. More...
 
struct  TypeInfo< Type::INT8 >
 TypeInfo specialization for signed 8-bit integer (INT8) tensors. More...
 
struct  UnscaleOp
 Inverse of ScaleOp: maps normalized outputs back to the original feature range. More...
 
class  Unscaling
 Output unscaling layer that reverts normalization back to the original feature ranges. More...
 
struct  Variable
 Single dataset column descriptor: name, role, type, scaler, and optional categories. More...
 
class  VGG16
 Factory neural network reproducing the VGG-16 architecture. More...
 

Typedefs

using bfloat16 = __nv_bfloat16
 
template<typename T, size_t N>
using array = Eigen::array<T, N>
 

Enumerations

enum class  Device { Auto , CPU , CUDA }
 Execution device selection for OpenNN runtime (auto-detected, CPU or CUDA GPU). More...
 
enum class  Type { Auto , FP32 , BF16 , INT8 }
 Numeric precision used for training or inference tensors. More...
 
enum class  SampleRole { Training , Validation , Testing , None }
 Role of a sample in a dataset split. More...
 
enum class  LayerType {
  Addition , Bounding , Convolutional , ConvolutionalRelu ,
  Dense , DenseRelu , Embedding , Flatten ,
  MultiHeadAttention , Normalization3d , Pooling , Pooling3d ,
  Recurrent , Scaling , Unscaling
}
 Identifier of every concrete layer subclass shipped with OpenNN. More...
 
enum class  PoolingMethod { MaxPooling , AveragePooling }
 Pooling reduction method used by Pooling and Pooling3d layers. More...
 
enum  DateFormat { AUTO , DMY , MDY , YMD }
 Order of the day, month, and year fields in a date string (AUTO probes the input). More...
 
enum class  VariableType {
  None , Numeric , Binary , Categorical ,
  DateTime , Constant
}
 Data type of a dataset Variable. More...
 
enum class  ScalerMethod {
  None , MinimumMaximum , MeanStandardDeviation , StandardDeviation ,
  Logarithm , ImageMinMax
}
 Feature scaling strategy applied to a Variable before training. More...
 
enum class  VariableRole {
  None , Input , Target , Decoder ,
  InputTarget , Time
}
 Role a Variable plays in a dataset (input feature, target, decoder, time axis, etc.). More...
 

Functions

template<Type... Supported, typename F>
void visit_type (Type t, F &&f)
 Dispatches f with the TypeInfo of the runtime Type t (must be in Supported).
 
template<Type... Supported, typename F>
void visit_type_pair (Type t_in, Type t_out, F &&f)
 Dispatches f with the TypeInfo pair for an input and output runtime Type.
 
cudnnDataType_t to_cudnn (Type type) noexcept
 Returns the cuDNN data type matching the given OpenNN Type (Auto resolves to FP32).
 
cudaDataType_t to_cuda (Type type) noexcept
 Returns the CUDA data type matching the given OpenNN Type (Auto resolves to FP32).
 
Index type_bytes (Type type) noexcept
 Returns the byte size of one element of the given OpenNN Type.
 
bool is_gpu ()
 Returns true when the resolved configuration runs on a CUDA GPU.
 
bool is_cpu ()
 Returns true when the resolved configuration runs on CPU.
 
bool is_bf16_training ()
 Returns true when training is configured to use BF16 precision.
 
bool is_bf16_inference ()
 Returns true when inference is configured to use BF16 precision.
 
Device current_device ()
 Returns the active runtime device (CUDA if available, otherwise CPU).
 
Correlation linear_correlation (const VectorR &, const VectorR &)
 Pearson linear correlation between two equal-length vectors.
 
Correlation logarithmic_correlation (const VectorR &, const VectorR &)
 Logarithmic correlation: fits y = a + b * log(x) and returns the resulting fit.
 
Correlation exponential_correlation (const VectorR &, const VectorR &)
 Exponential correlation: fits y = a * exp(b * x) and returns the resulting fit.
 
Correlation power_correlation (const VectorR &, const VectorR &)
 Power correlation: fits y = a * x^b and returns the resulting fit.
 
Correlation logistic_correlation (const VectorR &, const VectorR &)
 Logistic correlation between two vectors (binary or continuous targets).
 
Correlation logistic_correlation (const VectorR &, const MatrixR &)
 Logistic correlation between a vector predictor and a one-hot matrix target.
 
Correlation logistic_correlation (const MatrixR &, const VectorR &)
 Logistic correlation between a one-hot matrix predictor and a vector target.
 
Correlation logistic_correlation (const MatrixR &, const MatrixR &)
 Logistic correlation between two one-hot matrices.
 
Correlation point_biserial_correlation (const VectorR &, const VectorR &)
 Point-biserial correlation between a binary vector and a continuous vector.
 
Correlation eta_squared_correlation (const VectorR &, const MatrixR &)
 Eta-squared (effect-size) correlation between a continuous vector and a categorical matrix.
 
Correlation correlation (const MatrixR &, const MatrixR &)
 Generic correlation between two matrices, dispatching on column types (binary, categorical, continuous).
 
Correlation linear_correlation_spearman (const VectorR &, const VectorR &)
 Spearman rank correlation between two vectors using a linear fit on ranks.
 
VectorR calculate_spearman_ranks (const VectorR &)
 Computes Spearman ranks (average rank for ties) for the entries of a vector.
 
Correlation logistic_correlation_spearman (const VectorR &, const VectorR &)
 Spearman-rank logistic correlation between two vectors.
 
Correlation correlation_spearman (const MatrixR &, const MatrixR &)
 Generic Spearman correlation between two matrices, dispatching on column types.
 
float r_correlation_to_z_correlation (const float)
 Fisher r-to-z transform of a correlation coefficient.
 
float z_correlation_to_r_correlation (const float)
 Inverse Fisher z-to-r transform.
 
pair< float, float > confidence_interval_z_correlation (const float, Index)
 Returns the [lower, upper] confidence interval for a correlation given its sample size.
 
VectorR autocorrelations (const VectorR &, Index=10)
 Autocorrelations of a series for lags 0..max_lag.
 
VectorR cross_correlations (const VectorR &, const VectorR &, Index)
 Cross-correlations between two series for lags 0..max_lag.
 
MatrixR get_correlation_values (const Tensor< Correlation, 2 > &)
 Extracts the coefficient r from a 2D tensor of Correlation values.
 
const EnumMap< SampleRole > & sample_role_map ()
 Returns the bidirectional string/enum map for SampleRole.
 
const string & sample_role_to_string (SampleRole role)
 Returns the canonical string name for a SampleRole.
 
SampleRole string_to_sample_role (const string &name)
 Parses a string (name or "0"/"1"/"2"/"3") into the matching SampleRole.
 
void mean_squared_error (const TensorView &input, const TensorView &target, float &error, float *workspace_device)
 Computes the mean squared error between predictions and targets.
 
void mean_squared_error_gradient (const TensorView &input, const TensorView &target, const TensorView &input_delta)
 Writes the MSE gradient with respect to the predictions into input_delta.
 
void normalized_squared_error (const TensorView &input, const TensorView &target, float coefficient, float &error, float *workspace_device)
 Computes the squared error normalized by a dataset-level coefficient.
 
void normalized_squared_error_gradient (const TensorView &input, const TensorView &target, float coefficient, const TensorView &input_delta)
 Writes the normalized-squared-error gradient with respect to the predictions into input_delta.
 
void weighted_squared_error (const TensorView &input, const TensorView &target, float pos_w, float neg_w, float &error, float *workspace_device)
 Computes the binary squared error weighted asymmetrically for positive and negative classes.
 
void weighted_squared_error_gradient (const TensorView &input, const TensorView &target, float pos_w, float neg_w, float coefficient, const TensorView &input_delta)
 Writes the gradient of the weighted squared error scaled by coefficient into input_delta.
 
void binary_cross_entropy (const TensorView &input, const TensorView &target, float &error, float *workspace_device)
 Computes the binary cross-entropy between predicted probabilities and binary targets.
 
void categorical_cross_entropy (const TensorView &input, const TensorView &target, float &error, float *workspace_device)
 Computes the multi-class (categorical) cross-entropy between softmax probabilities and one-hot targets.
 
void cross_entropy_gradient (const TensorView &input, const TensorView &target, const TensorView &input_delta)
 Writes the cross-entropy gradient with respect to the (pre-softmax/logit) predictions into input_delta.
 
void minkowski_error (const TensorView &input, const TensorView &target, float power, float &error, float *workspace_device)
 Computes the Minkowski error sum(|input - target|^power) for the given power exponent.
 
void minkowski_error_gradient (const TensorView &input, const TensorView &target, float power, const TensorView &input_delta)
 Writes the Minkowski-error gradient with respect to the predictions into input_delta.
 
void cross_entropy_3d (const TensorView &input, const TensorView &target, float &error, Index &active_tokens_out, Index &correct_tokens_out, float *errors_device=nullptr)
 Computes 3-D (sequence) cross-entropy used by transformer-style targets, ignoring padded positions.
 
void cross_entropy_3d_gradient (const TensorView &input, const TensorView &target, const TensorView &input_delta, Index active_tokens_count)
 Writes the 3-D cross-entropy gradient into input_delta, normalizing by the host-side active-token count.
 
void cross_entropy_3d_gradient_device_count (const TensorView &input, const TensorView &target, const TensorView &input_delta, const float *active_tokens_count_device)
 Variant of cross_entropy_3d_gradient that reads the active-token count from device memory.
 
void l1_regularization (const TensorView &parameters, float lambda, float &penalty)
 Computes the L1 regularization penalty lambda * sum(|parameters|).
 
void l1_regularization_gradient (const TensorView &parameters, float lambda, const TensorView &gradient)
 Adds the L1 regularization gradient lambda * sign(parameters) into the gradient tensor.
 
void l2_regularization (const TensorView &parameters, float lambda, float &penalty)
 Computes the L2 regularization penalty lambda * sum(parameters^2).
 
void l2_regularization_gradient (const TensorView &parameters, float lambda, const TensorView &gradient)
 Adds the L2 regularization gradient 2 * lambda * parameters into the gradient tensor.
 
Tensor3 load_image (const filesystem::path &)
 Loads an image from disk into a rank-3 (height, width, channels) tensor.
 
void load_image (const filesystem::path &, float *dst, Index expected_height, Index expected_width, Index expected_channels, bool divide_by_255=false)
 Loads an image into a pre-allocated float buffer at the given shape.
 
Tensor3 resize_image (const Tensor3 &, Index, Index)
 Returns a resized copy of an image at the requested height and width.
 
void reflect_image_horizontal (Tensor3 &)
 Mirrors the image horizontally (left-right) in place.
 
void reflect_image_vertical (Tensor3 &)
 Mirrors the image vertically (top-bottom) in place.
 
void rotate_image (const Tensor3 &, Tensor3 &, float)
 Rotates the image by the given angle (radians) into the destination tensor.
 
void translate_image_x (const Tensor3 &, Tensor3 &, Index)
 Translates the image along the X axis by the given number of pixels.
 
void translate_image_y (const Tensor3 &, Tensor3 &, Index)
 Translates the image along the Y axis by the given number of pixels.
 
void atomic_rename (const filesystem::path &from, const filesystem::path &to)
 Atomically renames a file, replacing the destination if needed.
 
void add_json_field (JsonWriter &writer, const string &name, const string &value)
 
void write_json (JsonWriter &writer, initializer_list< pair< const char *, string > > props)
 
float read_json_type (const Json *root, const string &field)
 
long read_json_index (const Json *root, const string &field)
 
bool read_json_bool (const Json *root, const string &field)
 
string read_json_string (const Json *root, const string &field)
 
string read_json_string_fallback (const Json *root, initializer_list< string > names)
 
const Jsonrequire_json_field (const Json *root, const string &field)
 
template<typename Func>
void for_json_items (const Json *parent, const char *tag, long count, Func func)
 
JsonDocument load_json_file (const filesystem::path &file_name)
 
const Jsonget_json_root (const JsonDocument &document, const string &tag)
 
const EnumMap< LayerType > & layer_type_map ()
 Returns the bidirectional mapping between LayerType values and their string names.
 
const string & layer_type_to_string (LayerType type)
 Returns the string name associated with the given LayerType.
 
LayerType string_to_layer_type (const string &name)
 Returns the LayerType corresponding to the given string name.
 
void check_rank (const Shape &shape, initializer_list< int > allowed, const char *layer, const char *what)
 Throws if shape rank is not one of allowed.
 
void pad (const TensorView &input, TensorView &output)
 Pads the input tensor and writes the result into output.
 
void bound (const TensorView &input, const TensorView &lower_bounds, const TensorView &upper_bounds, TensorView &output)
 Clamps each element of input to the [lower_bounds, upper_bounds] range.
 
void bound_cpu (const TensorView &input, const TensorView &lower_bounds, const TensorView &upper_bounds, TensorView &output)
 CPU implementation of bound().
 
void scale (const TensorView &input, const TensorView &minimums, const TensorView &maximums, const TensorView &means, const TensorView &standard_deviations, const TensorView &scalers, float min_range, float max_range, TensorView &output)
 Applies per-feature scaling (mean/std, min/max, or other scalers) to a tensor.
 
void scale_cpu (const TensorView &input, const TensorView &minimums, const TensorView &maximums, const TensorView &means, const TensorView &standard_deviations, const TensorView &scalers, float min_range, float max_range, TensorView &output)
 CPU implementation of scale().
 
void unscale (const TensorView &input, const TensorView &minimums, const TensorView &maximums, const TensorView &means, const TensorView &standard_deviations, const TensorView &scalers, float min_range, float max_range, TensorView &output)
 Inverse of scale(); reconstructs original values from a previously scaled tensor.
 
void unscale_cpu (const TensorView &input, const TensorView &minimums, const TensorView &maximums, const TensorView &means, const TensorView &standard_deviations, const TensorView &scalers, float min_range, float max_range, TensorView &output)
 CPU implementation of unscale().
 
void copy (const TensorView &source, TensorView &destination)
 Copies the contents of source into destination, dispatching to CPU or GPU as needed.
 
void copy_cpu (const TensorView &source, TensorView &destination)
 CPU implementation of copy().
 
void add (const TensorView &input_1, const TensorView &input_2, TensorView &output)
 Element-wise addition: output = input_1 + input_2.
 
void add_cpu (const TensorView &input_1, const TensorView &input_2, TensorView &output)
 CPU implementation of add().
 
void multiply (const TensorView &input_a, bool transpose_a, const TensorView &input_b, bool transpose_b, TensorView &output, float alpha=1.0f, float beta=0.0f)
 General matrix multiply: output = alpha * op(input_a) * op(input_b) + beta * output.
 
void multiply_cpu (const TensorView &input_a, bool transpose_a, const TensorView &input_b, bool transpose_b, TensorView &output, float alpha=1.0f, float beta=0.0f)
 CPU implementation of multiply().
 
void softmax (TensorView &output)
 Applies softmax in place along the trailing dimension of output.
 
void softmax_cpu (TensorView &output)
 CPU implementation of softmax().
 
void max_pooling_3d_forward (const TensorView &input, TensorView &output, TensorView &maximal_indices, bool is_training)
 Forward pass of 3D max pooling; records argmax positions when training.
 
void max_pooling_3d_forward_cpu (const TensorView &input, TensorView &output, TensorView &maximal_indices, bool is_training)
 CPU implementation of max_pooling_3d_forward().
 
void average_pooling_3d_forward (const TensorView &input, TensorView &output)
 Forward pass of 3D average pooling.
 
void average_pooling_3d_forward_cpu (const TensorView &input, TensorView &output)
 CPU implementation of average_pooling_3d_forward().
 
void max_pooling_3d_backward (const TensorView &maximal_indices, const TensorView &output_delta, TensorView &input_delta)
 Backward pass for 3D max pooling; routes gradients to argmax positions.
 
void max_pooling_3d_backward_cpu (const TensorView &maximal_indices, const TensorView &output_delta, TensorView &input_delta)
 CPU implementation of max_pooling_3d_backward().
 
void average_pooling_3d_backward (const TensorView &input, const TensorView &output_delta, TensorView &input_delta)
 Backward pass for 3D average pooling.
 
void average_pooling_3d_backward_cpu (const TensorView &input, const TensorView &output_delta, TensorView &input_delta)
 CPU implementation of average_pooling_3d_backward().
 
void split_heads (const TensorView &source, TensorView &destination)
 Reshapes a multi-head attention tensor by splitting the last axis into heads.
 
void split_heads_cpu (const TensorView &source, TensorView &destination)
 CPU implementation of split_heads().
 
void merge_heads (const TensorView &source, TensorView &destination)
 Inverse of split_heads(); merges per-head tensors back into a single representation.
 
void merge_heads_cpu (const TensorView &source, TensorView &destination)
 CPU implementation of merge_heads().
 
void sort_string_vector (vector< string > &)
 Sorts a vector of strings in place in ascending lexicographical order.
 
vector< string > concatenate_string_vectors (const vector< string > &, const vector< string > &)
 Concatenates two string vectors and returns the resulting vector.
 
string formatNumber (float, int)
 Formats a floating point number as a string using the given number of decimal digits.
 
float round_to_precision (float, const int &)
 Rounds the given floating point value to the requested number of significant digits.
 
void throw_if (bool condition, const string &message, const source_location &loc=source_location::current())
 
template<typename T>
ostream & operator<< (ostream &os, const vector< T > &vec)
 
const string & pooling_method_to_string (PoolingMethod method)
 
PoolingMethod string_to_pooling_method (const string &name)
 
Statsglobal_stats ()
 
bool & enabled ()
 
void set_seed (unsigned seed)
 Seeds the library-wide pseudo-random number generator.
 
long long get_seed ()
 Returns the seed currently used by the library RNG.
 
float random_uniform (float=-1, float=1)
 Draws a float uniformly in [min, max].
 
Index random_integer (Index, Index)
 Draws an integer uniformly in [min, max].
 
bool random_bool (float=0.5)
 Draws a boolean that is true with the given probability.
 
void set_random_uniform (MatrixR &, float=-0.1, float=0.1)
 Fills the matrix with uniform random values in [min, max].
 
void set_random_uniform (VectorMap, float=-0.1, float=0.1)
 Fills the vector map with uniform random values in [min, max].
 
void set_random_normal (MatrixMap, float=0, float=1)
 Fills the matrix with normal random values of the given mean and standard deviation.
 
void set_random_integer (MatrixR &, Index, Index)
 Fills the matrix with uniform random integers in [min, max].
 
void shuffle (VectorB &vector_to_shuffle)
 Randomly permutes the entries of a boolean vector in place.
 
template<typename T>
void shuffle_vector (vector< T > &)
 Randomly permutes the entries of the given vector in place.
 
void shuffle_vector_blocks (vector< Index > &, size_t=20)
 Shuffles contiguous blocks of the given length while preserving in-block order.
 
Index get_random_element (const vector< Index > &)
 Picks one element uniformly at random from the given vector.
 
float glorot_limit (Index fan_in, Index fan_out)
 Returns the Glorot/Xavier uniform initialization limit sqrt(6 / (fan_in + fan_out)).
 
void register_classes ()
 
void scale_mean_standard_deviation (MatrixMap, Index, const Descriptives &)
 Standardises a column of the matrix in place using its descriptives' mean and standard deviation.
 
void scale_standard_deviation (MatrixMap, Index, const Descriptives &)
 Divides a column of the matrix by its standard deviation in place.
 
void scale_minimum_maximum (MatrixMap, Index, const Descriptives &, float=-1.0f, float=1.0f)
 Rescales a column to the [min_range, max_range] interval using its descriptives.
 
void scale_logarithmic (MatrixMap, Index)
 Applies an element-wise logarithm to the given column.
 
void unscale_minimum_maximum (MatrixMap, Index, const Descriptives &, float=-1.0f, float=1.0f)
 Inverse of scale_minimum_maximum(): reconstructs original values for the given column.
 
void unscale_mean_standard_deviation (MatrixMap, Index, const Descriptives &)
 Inverse of scale_mean_standard_deviation() for the given column.
 
void unscale_standard_deviation (MatrixMap, Index, const Descriptives &)
 Inverse of scale_standard_deviation() for the given column.
 
void unscale_logarithmic (MatrixMap, Index)
 Inverse of scale_logarithmic() for the given column.
 
void unscale_image_minimum_maximum (MatrixMap, Index)
 Maps a column back from [-1, 1] to the [0, 255] image-pixel range.
 
float minimum (const MatrixR &)
 Returns the smallest finite element of a matrix.
 
float minimum (const VectorR &)
 Returns the smallest finite element of a vector.
 
float minimum (const VectorR &, const vector< Index > &)
 Returns the smallest finite element of the selected rows of a vector.
 
VectorR column_minimums (const Tensor2 &, const vector< Index > &={}, const vector< Index > &={})
 Per-column minimums of a 2D tensor.
 
float maximum (const MatrixR &)
 Returns the largest finite element of a matrix.
 
float maximum (const VectorR &)
 Returns the largest finite element of a vector.
 
float maximum (const VectorR &, const vector< Index > &)
 Returns the largest finite element of the selected rows of a vector.
 
VectorR column_maximums (const Tensor2 &, const vector< Index > &={}, const vector< Index > &={})
 Per-column maximums of a 2D tensor, optionally restricted to a row/column subset.
 
float range (const VectorR &)
 Returns the maximum minus the minimum of a vector.
 
float mean (const VectorR &)
 Arithmetic mean of a vector, ignoring NaNs.
 
float mean (const MatrixR &, Index)
 Arithmetic mean of a matrix column, ignoring NaNs.
 
VectorR mean (const MatrixR &)
 Column-wise arithmetic means of a matrix.
 
VectorR mean (const MatrixR &, const vector< Index > &, const vector< Index > &)
 Column-wise means of a matrix restricted to the given rows and columns.
 
float median (const VectorR &)
 Median of a vector.
 
float median (const MatrixR &, Index)
 Median of a single matrix column.
 
VectorR median (const MatrixR &)
 Column-wise medians of a matrix.
 
VectorR median (const MatrixR &, const vector< Index > &)
 Column-wise medians of the selected columns.
 
VectorR median (const MatrixR &, const vector< Index > &, const vector< Index > &)
 Column-wise medians restricted to the given rows and columns.
 
float variance (const VectorR &)
 Sample variance of a vector.
 
float variance (const VectorR &, const VectorI &)
 Sample variance of the selected entries of a vector.
 
float standard_deviation (const VectorR &)
 Sample standard deviation of a vector.
 
VectorR standard_deviation (const VectorR &, Index)
 Rolling standard deviation of a vector over a window of the given size.
 
VectorR quartiles (const VectorR &)
 Returns [Q1, Q2, Q3] of a vector.
 
VectorR quartiles (const VectorR &, const vector< Index > &)
 Returns [Q1, Q2, Q3] of the selected entries of a vector.
 
BoxPlot box_plot (const VectorR &)
 Five-number summary (box plot) of a vector.
 
BoxPlot box_plot (const VectorR &, const vector< Index > &)
 Five-number summary (box plot) of the selected entries of a vector.
 
Descriptives vector_descriptives (const VectorR &)
 Returns the (min, max, mean, std) descriptives of a vector.
 
vector< Descriptivesdescriptives (const MatrixR &)
 Returns the per-column descriptives of a matrix.
 
vector< Descriptivesdescriptives (const MatrixR &, const vector< Index > &, const vector< Index > &)
 Returns per-column descriptives restricted to the given rows and columns.
 
Histogram histogram (const VectorR &, Index=10)
 Builds an equal-width histogram of a vector.
 
Histogram histogram_centered (const VectorR &, float=0.0f, Index=10)
 Builds a histogram with one bin centered on the given value.
 
Histogram histogram (const VectorB &)
 Builds a two-bin histogram counting false/true entries.
 
Histogram histogram (const VectorI &, Index=10)
 Builds an equal-width histogram of an integer vector.
 
vector< Histogramhistograms (const MatrixR &, Index=10)
 Builds one histogram per matrix column.
 
VectorI total_frequencies (const vector< Histogram > &)
 Sums the per-bin frequencies across a collection of histograms.
 
Index minimal_index (const VectorR &)
 Index of the smallest element in a vector.
 
VectorI minimal_indices (const VectorR &, Index)
 Indices of the n smallest elements of a vector.
 
VectorI minimal_indices (const MatrixR &)
 Row/column coordinates of the smallest element of a matrix.
 
Index maximal_index (const VectorR &)
 Index of the largest element in a vector.
 
VectorI maximal_indices (const VectorR &, Index)
 Indices of the n largest elements of a vector.
 
VectorI maximal_indices (const MatrixR &)
 Row/column coordinates of the largest element of a matrix.
 
bool row_finite (const VectorR &values, Index i)
 Returns true if the i-th entry of the vector is finite.
 
bool row_finite (const MatrixR &matrix, Index i)
 Returns true if every entry in row i of the matrix is finite.
 
VectorR slice_rows (const VectorR &values, const vector< Index > &indices)
 Returns a copy of the vector containing only the entries at the given indices.
 
MatrixR slice_rows (const MatrixR &matrix, const vector< Index > &indices)
 Returns a copy of the matrix containing only the rows at the given indices.
 
VectorR filter_missing_values (const VectorR &)
 Returns a copy of the vector with NaN entries removed.
 
template<typename X, typename Y>
pair< X, Y > filter_missing_values (const X &x, const Y &y)
 Returns x and y restricted to rows where both are finite (row counts must match).
 
bool is_contiguous (const vector< Index > &indices)
 Returns true if the sorted indices form a contiguous run (each entry equals the previous plus one).
 
template<typename T>
bool is_binary (const T &tensor)
 Returns true if every non-NaN entry of the tensor is exactly 0.0 or 1.0.
 
MatrixR append_rows (const MatrixR &, const MatrixR &)
 Returns the row-wise concatenation of two matrices with matching column counts.
 
template<typename T>
vector< T > gather_by_index (const vector< T > &data, const vector< Index > &indices)
 Returns the elements of data at the given indices.
 
vector< Index > build_feasible_rows_mask (const MatrixR &outputs, const VectorR &minimums, const VectorR &maximums)
 Returns the indices of the rows of outputs that lie within the per-column bounds.
 
template<typename T>
bool is_constant (const T &tensor)
 Returns true if every non-NaN entry of the tensor equals the first finite entry.
 
vector< Index > get_true_indices (const VectorB &flags)
 Returns the positions of the true entries in a boolean vector.
 
VectorI calculate_rank (const VectorR &, bool ascending=true)
 Returns the rank of each element (1-based), ascending by default.
 
vector< Index > get_elements_greater_than (const vector< Index > &, Index)
 Returns the entries of indices that are strictly greater than the given threshold.
 
VectorI get_nearest_points (const MatrixR &, const VectorR &, int=1)
 Finds the n rows of the matrix closest to the given point by Euclidean distance.
 
void fill_tensor_data (const MatrixR &, const vector< Index > &, const vector< Index > &, float *, bool=true, int contiguous=-1)
 Copies the selected sub-matrix into a flat float buffer.
 
VectorR perform_Householder_QR_decomposition (const MatrixR &, const VectorR &)
 Solves a linear least-squares problem via Householder QR decomposition.
 
VectorMap vector_map (const MatrixR &, Index)
 Returns an Eigen VectorMap that views a single column of a matrix without copying.
 
vector< string > get_tokens (const string &, const string &)
 Splits a string on every occurrence of any character in the separator set.
 
vector< string_view > get_token_views (string_view, char)
 Splits a string view on the given separator, returning views into the original buffer.
 
string_view trim_view (string_view)
 Returns a view onto the input with leading and trailing whitespace removed.
 
vector< string > tokenize (const string &)
 Splits the input on whitespace into individual tokens.
 
vector< string_view > tokenize_views (string_view)
 Whitespace-tokenises a string view, returning views into the source buffer.
 
vector< string > convert_string_vector (const vector< vector< string > > &, const string &)
 Joins each inner vector with the separator, returning one flattened string per row.
 
bool is_numeric_string (string_view)
 Returns true if the string can be parsed as a numeric literal.
 
bool is_date_time_string (string_view)
 Returns true if the string matches one of the supported date/time formats.
 
time_t date_to_timestamp (const string &, Index=0, const DateFormat &format=AUTO)
 Parses a date/time string into a Unix timestamp.
 
void replace_all_appearances (string &, const string &, const string &)
 Replaces every occurrence of a substring with another, in place.
 
void replace_all_word_appearances (string &, const string &, const string &)
 Replaces every whole-word occurrence of a token with another, in place.
 
string get_trimmed (const string &)
 Returns a copy of the string with leading and trailing whitespace removed.
 
bool has_numbers (const vector< string > &)
 Returns true if any element of the vector parses as a number.
 
bool has_numbers (const vector< string_view > &)
 Returns true if any element of the vector parses as a number.
 
void replace (string &, const string &, const string &)
 In-place replacement of every occurrence of a substring with another.
 
void display_progress_bar (int, int)
 Prints a textual progress bar to stdout for an in-progress operation.
 
string get_time (float)
 Formats a duration in seconds as a human-readable HH:MM:SS string.
 
string get_first_word (const string &)
 Returns the first whitespace-delimited word of a string.
 
template<typename T>
string vector_to_string (const vector< T > &values, const string &separator=" ")
 Serializes a vector to a string with the given element separator.
 
template<typename Derived>
string vector_to_string (const Eigen::DenseBase< Derived > &values, const string &separator=" ")
 Serializes an Eigen dense expression to a string with the given separator.
 
void string_to_vector (const string &input, VectorR &values)
 Parses a whitespace-separated string of floats into a VectorR.
 
template<typename T, size_t Rank>
string tensor_to_string (const TensorR< Rank > &values, const string &separator=" ")
 Serializes a tensor's flat data to a string with the given separator.
 
template<typename T, size_t Rank>
void string_to_tensor (const string &input, TensorR< Rank > &values)
 Parses a whitespace-separated string into the flat storage of a tensor.
 
bool contains (const vector< string > &, const string &)
 Returns true if the vector contains the given element.
 
bool contains (const vector< string > &, string_view)
 Returns true if the vector contains the given element.
 
int to_int (Index value)
 
float to_type (Index value)
 
Index align_up (Index value, Index alignment)
 
Index get_aligned_size (Index size)
 
Index get_aligned_bytes (Index n_bytes)
 
Index get_aligned_bytes (Index count, Type dtype)
 
bool is_aligned (const void *ptr)
 
Index get_aligned_size (const vector< TensorSpec > &specs)
 
Index get_aligned_size (const vector< vector< TensorSpec > > &specs)
 
Index get_aligned_bytes (const vector< TensorSpec > &specs)
 
Index get_aligned_bytes (const vector< vector< TensorSpec > > &specs)
 
Index get_aligned_bytes (const vector< Shape > &shapes, Type dtype)
 
Index get_aligned_bytes (const vector< TensorSpec > &specs, Type dtype)
 
Index get_aligned_bytes (const vector< vector< TensorSpec > > &specs, Type dtype)
 
TensorViewview_at_slot_or (vector< TensorView > &views, const vector< size_t > &slots, size_t i, TensorView &fallback)
 
TensorViewview_at_slot_or (vector< vector< TensorView > > &views, const vector< size_t > &slots, size_t i, TensorView &fallback)
 
string shape_to_string (const Shape &, const string &=" ")
 Serializes a shape as a separator-joined string of dimensions.
 
Shape string_to_shape (const string &, const string &=" ")
 Parses a separator-joined string of dimensions into a Shape.
 
template<typename... Vs>
size_t hash_combine (const Vs &... values)
 Boost-style hash combine that mixes any number of hashable values into a single size_t.
 
ThreadPoolDevice & get_device ()
 Convenience accessor for the global Eigen ThreadPoolDevice.
 
const EnumMap< VariableType > & variable_type_map ()
 Returns the bidirectional string/enum map for VariableType.
 
const string & variable_type_to_string (VariableType type)
 Returns the canonical string name for a VariableType.
 
VariableType string_to_variable_type (const string &name)
 Parses a string into the matching VariableType enumerator.
 
const EnumMap< ScalerMethod > & scaler_method_map ()
 Returns the bidirectional string/enum map for ScalerMethod.
 
const string & scaler_method_to_string (ScalerMethod method)
 Returns the canonical string name for a ScalerMethod.
 
ScalerMethod string_to_scaler_method (const string &name)
 Parses a string into the matching ScalerMethod enumerator.
 
const EnumMap< VariableRole > & variable_role_map ()
 Returns the bidirectional string/enum map for VariableRole.
 
const string & variable_role_to_string (VariableRole role)
 Returns the canonical string name for a VariableRole.
 
VariableRole string_to_variable_role (const string &name)
 Parses a string into a VariableRole; "Id" is mapped to VariableRole::None.
 
bool role_matches (VariableRole actual, VariableRole query)
 Returns true if actual satisfies query, treating InputTarget as Input or Target.
 

Variables

constexpr float GRADIENT_NORM_EPS = 1e-6f
 
constexpr float EPSILON = numeric_limits<float>::epsilon()
 
constexpr float MAX = numeric_limits<float>::max()
 
constexpr float NEG_INFINITY = -numeric_limits<float>::infinity()
 
constexpr float QUIET_NAN = numeric_limits<float>::quiet_NaN()
 
constexpr float SOFTMAX_MASK_VALUE = float(-1e9f)
 
static constexpr Index ALIGN_BYTES = EIGEN_MAX_ALIGN_BYTES
 
static constexpr Index ALIGN_ELEMENTS = ALIGN_BYTES / sizeof(float)
 
constexpr cudaDataType_t CUDA_REDUCTION_DTYPE = CUDA_R_32F
 
constexpr cublasComputeType_t CUBLAS_COMPUTE_DTYPE = CUBLAS_COMPUTE_32F_FAST_TF32
 

Typedef Documentation

◆ array

template<typename T, size_t N>
using opennn::array = Eigen::array<T, N>

◆ bfloat16

Enumeration Type Documentation

◆ DateFormat

Order of the day, month, and year fields in a date string (AUTO probes the input).

Enumerator
AUTO 
DMY 
MDY 
YMD 

◆ Device

enum class opennn::Device
strong

Execution device selection for OpenNN runtime (auto-detected, CPU or CUDA GPU).

Enumerator
Auto 
CPU 
CUDA 

◆ LayerType

enum class opennn::LayerType
strong

Identifier of every concrete layer subclass shipped with OpenNN.

Enumerator
Addition 
Bounding 
Convolutional 
ConvolutionalRelu 
Dense 
DenseRelu 
Embedding 
Flatten 
MultiHeadAttention 
Normalization3d 
Pooling 
Pooling3d 
Recurrent 
Scaling 
Unscaling 

◆ PoolingMethod

enum class opennn::PoolingMethod
strong

Pooling reduction method used by Pooling and Pooling3d layers.

Enumerator
MaxPooling 
AveragePooling 

◆ SampleRole

enum class opennn::SampleRole
strong

Role of a sample in a dataset split.

Enumerator
Training 
Validation 
Testing 
None 

◆ ScalerMethod

enum class opennn::ScalerMethod
strong

Feature scaling strategy applied to a Variable before training.

Enumerator
None 
MinimumMaximum 
MeanStandardDeviation 
StandardDeviation 
Logarithm 
ImageMinMax 

◆ Type

enum class opennn::Type
strong

Numeric precision used for training or inference tensors.

Enumerator
Auto 
FP32 
BF16 
INT8 

◆ VariableRole

enum class opennn::VariableRole
strong

Role a Variable plays in a dataset (input feature, target, decoder, time axis, etc.).

Enumerator
None 
Input 
Target 
Decoder 
InputTarget 
Time 

◆ VariableType

enum class opennn::VariableType
strong

Data type of a dataset Variable.

Enumerator
None 
Numeric 
Binary 
Categorical 
DateTime 
Constant 

Function Documentation

◆ add()

void opennn::add ( const TensorView & input_1,
const TensorView & input_2,
TensorView & output )

Element-wise addition: output = input_1 + input_2.

◆ add_cpu()

void opennn::add_cpu ( const TensorView & input_1,
const TensorView & input_2,
TensorView & output )

CPU implementation of add().

◆ add_json_field()

void opennn::add_json_field ( JsonWriter & writer,
const string & name,
const string & value )

◆ align_up()

Index opennn::align_up ( Index value,
Index alignment )
inlinenodiscard

◆ append_rows()

MatrixR opennn::append_rows ( const MatrixR & ,
const MatrixR &  )
nodiscard

Returns the row-wise concatenation of two matrices with matching column counts.

◆ atomic_rename()

void opennn::atomic_rename ( const filesystem::path & from,
const filesystem::path & to )

Atomically renames a file, replacing the destination if needed.

◆ autocorrelations()

VectorR opennn::autocorrelations ( const VectorR & ,
Index = 10 )
nodiscard

Autocorrelations of a series for lags 0..max_lag.

Parameters
seriesInput time series.
max_lagMaximum lag to compute (default 10).

◆ average_pooling_3d_backward()

void opennn::average_pooling_3d_backward ( const TensorView & input,
const TensorView & output_delta,
TensorView & input_delta )

Backward pass for 3D average pooling.

◆ average_pooling_3d_backward_cpu()

void opennn::average_pooling_3d_backward_cpu ( const TensorView & input,
const TensorView & output_delta,
TensorView & input_delta )

CPU implementation of average_pooling_3d_backward().

◆ average_pooling_3d_forward()

void opennn::average_pooling_3d_forward ( const TensorView & input,
TensorView & output )

Forward pass of 3D average pooling.

◆ average_pooling_3d_forward_cpu()

void opennn::average_pooling_3d_forward_cpu ( const TensorView & input,
TensorView & output )

CPU implementation of average_pooling_3d_forward().

◆ binary_cross_entropy()

void opennn::binary_cross_entropy ( const TensorView & input,
const TensorView & target,
float & error,
float * workspace_device )

Computes the binary cross-entropy between predicted probabilities and binary targets.

◆ bound()

void opennn::bound ( const TensorView & input,
const TensorView & lower_bounds,
const TensorView & upper_bounds,
TensorView & output )

Clamps each element of input to the [lower_bounds, upper_bounds] range.

Parameters
inputSource tensor.
lower_boundsPer-element (or broadcastable) lower limits.
upper_boundsPer-element (or broadcastable) upper limits.
outputDestination tensor for the bounded values.

◆ bound_cpu()

void opennn::bound_cpu ( const TensorView & input,
const TensorView & lower_bounds,
const TensorView & upper_bounds,
TensorView & output )

CPU implementation of bound().

◆ box_plot() [1/2]

BoxPlot opennn::box_plot ( const VectorR & )
nodiscard

Five-number summary (box plot) of a vector.

◆ box_plot() [2/2]

BoxPlot opennn::box_plot ( const VectorR & ,
const vector< Index > &  )
nodiscard

Five-number summary (box plot) of the selected entries of a vector.

◆ build_feasible_rows_mask()

vector< Index > opennn::build_feasible_rows_mask ( const MatrixR & outputs,
const VectorR & minimums,
const VectorR & maximums )
nodiscard

Returns the indices of the rows of outputs that lie within the per-column bounds.

◆ calculate_rank()

VectorI opennn::calculate_rank ( const VectorR & ,
bool ascending = true )
nodiscard

Returns the rank of each element (1-based), ascending by default.

◆ calculate_spearman_ranks()

VectorR opennn::calculate_spearman_ranks ( const VectorR & )
nodiscard

Computes Spearman ranks (average rank for ties) for the entries of a vector.

◆ categorical_cross_entropy()

void opennn::categorical_cross_entropy ( const TensorView & input,
const TensorView & target,
float & error,
float * workspace_device )

Computes the multi-class (categorical) cross-entropy between softmax probabilities and one-hot targets.

◆ check_rank()

void opennn::check_rank ( const Shape & shape,
initializer_list< int > allowed,
const char * layer,
const char * what )
inline

Throws if shape rank is not one of allowed.

Parameters
shapeShape to validate (empty shapes are accepted).
allowedAcceptable rank values.
layerLayer name used in the error message.
whatDescription of the tensor being checked (e.g. "input").

◆ column_maximums()

VectorR opennn::column_maximums ( const Tensor2 & ,
const vector< Index > & = {},
const vector< Index > & = {} )
nodiscard

Per-column maximums of a 2D tensor, optionally restricted to a row/column subset.

◆ column_minimums()

VectorR opennn::column_minimums ( const Tensor2 & ,
const vector< Index > & = {},
const vector< Index > & = {} )
nodiscard

Per-column minimums of a 2D tensor.

Parameters
matrixSource matrix.
row_indicesOptional row subset (empty = all rows).
column_indicesOptional column subset (empty = all columns).

◆ concatenate_string_vectors()

vector< string > opennn::concatenate_string_vectors ( const vector< string > & ,
const vector< string > &  )

Concatenates two string vectors and returns the resulting vector.

◆ confidence_interval_z_correlation()

pair< float, float > opennn::confidence_interval_z_correlation ( const float ,
Index  )
nodiscard

Returns the [lower, upper] confidence interval for a correlation given its sample size.

◆ contains() [1/2]

bool opennn::contains ( const vector< string > & ,
const string &  )
nodiscard

Returns true if the vector contains the given element.

◆ contains() [2/2]

bool opennn::contains ( const vector< string > & ,
string_view  )
nodiscard

Returns true if the vector contains the given element.

◆ convert_string_vector()

vector< string > opennn::convert_string_vector ( const vector< vector< string > > & ,
const string &  )
nodiscard

Joins each inner vector with the separator, returning one flattened string per row.

◆ copy()

void opennn::copy ( const TensorView & source,
TensorView & destination )

Copies the contents of source into destination, dispatching to CPU or GPU as needed.

◆ copy_cpu()

void opennn::copy_cpu ( const TensorView & source,
TensorView & destination )

CPU implementation of copy().

◆ correlation()

Correlation opennn::correlation ( const MatrixR & ,
const MatrixR &  )
nodiscard

Generic correlation between two matrices, dispatching on column types (binary, categorical, continuous).

◆ correlation_spearman()

Correlation opennn::correlation_spearman ( const MatrixR & ,
const MatrixR &  )
nodiscard

Generic Spearman correlation between two matrices, dispatching on column types.

◆ cross_correlations()

VectorR opennn::cross_correlations ( const VectorR & ,
const VectorR & ,
Index  )
nodiscard

Cross-correlations between two series for lags 0..max_lag.

◆ cross_entropy_3d()

void opennn::cross_entropy_3d ( const TensorView & input,
const TensorView & target,
float & error,
Index & active_tokens_out,
Index & correct_tokens_out,
float * errors_device = nullptr )

Computes 3-D (sequence) cross-entropy used by transformer-style targets, ignoring padded positions.

Parameters
inputPredicted logits/probabilities with shape (batch, sequence, vocab).
targetToken ids or one-hot targets with the matching sequence layout.
errorOutput scalar holding the cumulative error across active tokens.
active_tokens_outOutput count of non-padding tokens that contributed to the error.
correct_tokens_outOutput count of correctly predicted tokens (for accuracy).
errors_deviceOptional device-side reduction workspace.

◆ cross_entropy_3d_gradient()

void opennn::cross_entropy_3d_gradient ( const TensorView & input,
const TensorView & target,
const TensorView & input_delta,
Index active_tokens_count )

Writes the 3-D cross-entropy gradient into input_delta, normalizing by the host-side active-token count.

◆ cross_entropy_3d_gradient_device_count()

void opennn::cross_entropy_3d_gradient_device_count ( const TensorView & input,
const TensorView & target,
const TensorView & input_delta,
const float * active_tokens_count_device )

Variant of cross_entropy_3d_gradient that reads the active-token count from device memory.

◆ cross_entropy_gradient()

void opennn::cross_entropy_gradient ( const TensorView & input,
const TensorView & target,
const TensorView & input_delta )

Writes the cross-entropy gradient with respect to the (pre-softmax/logit) predictions into input_delta.

◆ current_device()

Device opennn::current_device ( )
inlinenodiscard

Returns the active runtime device (CUDA if available, otherwise CPU).

◆ date_to_timestamp()

time_t opennn::date_to_timestamp ( const string & ,
Index = 0,
const DateFormat & format = AUTO )
nodiscard

Parses a date/time string into a Unix timestamp.

Parameters
date_stringDate or datetime literal to parse.
gmt_offsetNumber of hours to add when converting to UTC.
formatDay/month/year ordering, or AUTO to auto-detect.

◆ descriptives() [1/2]

vector< Descriptives > opennn::descriptives ( const MatrixR & )
nodiscard

Returns the per-column descriptives of a matrix.

◆ descriptives() [2/2]

vector< Descriptives > opennn::descriptives ( const MatrixR & ,
const vector< Index > & ,
const vector< Index > &  )
nodiscard

Returns per-column descriptives restricted to the given rows and columns.

◆ display_progress_bar()

void opennn::display_progress_bar ( int ,
int  )

Prints a textual progress bar to stdout for an in-progress operation.

Parameters
progress_indexCurrent step.
totalTotal number of steps.

◆ enabled()

bool & opennn::enabled ( )
inline

◆ eta_squared_correlation()

Correlation opennn::eta_squared_correlation ( const VectorR & ,
const MatrixR &  )
nodiscard

Eta-squared (effect-size) correlation between a continuous vector and a categorical matrix.

◆ exponential_correlation()

Correlation opennn::exponential_correlation ( const VectorR & ,
const VectorR &  )
nodiscard

Exponential correlation: fits y = a * exp(b * x) and returns the resulting fit.

◆ fill_tensor_data()

void opennn::fill_tensor_data ( const MatrixR & ,
const vector< Index > & ,
const vector< Index > & ,
float * ,
bool = true,
int contiguous = -1 )

Copies the selected sub-matrix into a flat float buffer.

Parameters
matrixSource data matrix.
row_indicesRows to copy.
column_indicesColumns to copy.
dataDestination buffer (caller-owned).
row_majorLay rows contiguously when true, columns when false.
contiguousOptional fast-path hint when -1 the layout is inferred.

◆ filter_missing_values() [1/2]

VectorR opennn::filter_missing_values ( const VectorR & )
nodiscard

Returns a copy of the vector with NaN entries removed.

◆ filter_missing_values() [2/2]

template<typename X, typename Y>
pair< X, Y > opennn::filter_missing_values ( const X & x,
const Y & y )
nodiscard

Returns x and y restricted to rows where both are finite (row counts must match).

◆ for_json_items()

template<typename Func>
void opennn::for_json_items ( const Json * parent,
const char * tag,
long count,
Func func )

◆ formatNumber()

string opennn::formatNumber ( float ,
int  )

Formats a floating point number as a string using the given number of decimal digits.

◆ gather_by_index()

template<typename T>
vector< T > opennn::gather_by_index ( const vector< T > & data,
const vector< Index > & indices )
nodiscard

Returns the elements of data at the given indices.

◆ get_aligned_bytes() [1/7]

Index opennn::get_aligned_bytes ( const vector< Shape > & shapes,
Type dtype )
inlinenodiscard

◆ get_aligned_bytes() [2/7]

Index opennn::get_aligned_bytes ( const vector< TensorSpec > & specs)
inlinenodiscard

◆ get_aligned_bytes() [3/7]

Index opennn::get_aligned_bytes ( const vector< TensorSpec > & specs,
Type dtype )
inlinenodiscard

◆ get_aligned_bytes() [4/7]

Index opennn::get_aligned_bytes ( const vector< vector< TensorSpec > > & specs)
inlinenodiscard

◆ get_aligned_bytes() [5/7]

Index opennn::get_aligned_bytes ( const vector< vector< TensorSpec > > & specs,
Type dtype )
inlinenodiscard

◆ get_aligned_bytes() [6/7]

Index opennn::get_aligned_bytes ( Index count,
Type dtype )
inlinenodiscard

◆ get_aligned_bytes() [7/7]

Index opennn::get_aligned_bytes ( Index n_bytes)
inlinenodiscard

◆ get_aligned_size() [1/3]

Index opennn::get_aligned_size ( const vector< TensorSpec > & specs)
inlinenodiscard

◆ get_aligned_size() [2/3]

Index opennn::get_aligned_size ( const vector< vector< TensorSpec > > & specs)
inlinenodiscard

◆ get_aligned_size() [3/3]

Index opennn::get_aligned_size ( Index size)
inlinenodiscard

◆ get_correlation_values()

MatrixR opennn::get_correlation_values ( const Tensor< Correlation, 2 > & )
nodiscard

Extracts the coefficient r from a 2D tensor of Correlation values.

◆ get_device()

ThreadPoolDevice & opennn::get_device ( )
inline

Convenience accessor for the global Eigen ThreadPoolDevice.

◆ get_elements_greater_than()

vector< Index > opennn::get_elements_greater_than ( const vector< Index > & ,
Index  )
nodiscard

Returns the entries of indices that are strictly greater than the given threshold.

◆ get_first_word()

string opennn::get_first_word ( const string & )
nodiscard

Returns the first whitespace-delimited word of a string.

◆ get_json_root()

const Json * opennn::get_json_root ( const JsonDocument & document,
const string & tag )
nodiscard

◆ get_nearest_points()

VectorI opennn::get_nearest_points ( const MatrixR & ,
const VectorR & ,
int = 1 )
nodiscard

Finds the n rows of the matrix closest to the given point by Euclidean distance.

◆ get_random_element()

Index opennn::get_random_element ( const vector< Index > & )
nodiscard

Picks one element uniformly at random from the given vector.

◆ get_seed()

long long opennn::get_seed ( )
nodiscard

Returns the seed currently used by the library RNG.

◆ get_time()

string opennn::get_time ( float )
nodiscard

Formats a duration in seconds as a human-readable HH:MM:SS string.

◆ get_token_views()

vector< string_view > opennn::get_token_views ( string_view ,
char  )
nodiscard

Splits a string view on the given separator, returning views into the original buffer.

◆ get_tokens()

vector< string > opennn::get_tokens ( const string & ,
const string &  )
nodiscard

Splits a string on every occurrence of any character in the separator set.

Parameters
inputSource string.
separatorsSet of single-character separators.
Returns
Tokens, with empty tokens dropped.

◆ get_trimmed()

string opennn::get_trimmed ( const string & )
nodiscard

Returns a copy of the string with leading and trailing whitespace removed.

◆ get_true_indices()

vector< Index > opennn::get_true_indices ( const VectorB & flags)
inlinenodiscard

Returns the positions of the true entries in a boolean vector.

◆ global_stats()

Stats & opennn::global_stats ( )
inline

◆ glorot_limit()

float opennn::glorot_limit ( Index fan_in,
Index fan_out )
inlinenodiscard

Returns the Glorot/Xavier uniform initialization limit sqrt(6 / (fan_in + fan_out)).

◆ has_numbers() [1/2]

bool opennn::has_numbers ( const vector< string > & )
nodiscard

Returns true if any element of the vector parses as a number.

◆ has_numbers() [2/2]

bool opennn::has_numbers ( const vector< string_view > & )
nodiscard

Returns true if any element of the vector parses as a number.

◆ hash_combine()

template<typename... Vs>
size_t opennn::hash_combine ( const Vs &... values)
nodiscard

Boost-style hash combine that mixes any number of hashable values into a single size_t.

◆ histogram() [1/3]

Histogram opennn::histogram ( const VectorB & )
nodiscard

Builds a two-bin histogram counting false/true entries.

◆ histogram() [2/3]

Histogram opennn::histogram ( const VectorI & ,
Index = 10 )
nodiscard

Builds an equal-width histogram of an integer vector.

◆ histogram() [3/3]

Histogram opennn::histogram ( const VectorR & ,
Index = 10 )
nodiscard

Builds an equal-width histogram of a vector.

Parameters
valuesInput data.
binsNumber of equal-width bins.

◆ histogram_centered()

Histogram opennn::histogram_centered ( const VectorR & ,
float = 0.0f,
Index = 10 )
nodiscard

Builds a histogram with one bin centered on the given value.

◆ histograms()

vector< Histogram > opennn::histograms ( const MatrixR & ,
Index = 10 )
nodiscard

Builds one histogram per matrix column.

◆ is_aligned()

bool opennn::is_aligned ( const void * ptr)
inlinenodiscard

◆ is_bf16_inference()

bool opennn::is_bf16_inference ( )
inlinenodiscard

Returns true when inference is configured to use BF16 precision.

◆ is_bf16_training()

bool opennn::is_bf16_training ( )
inlinenodiscard

Returns true when training is configured to use BF16 precision.

◆ is_binary()

template<typename T>
bool opennn::is_binary ( const T & tensor)
inlinenodiscard

Returns true if every non-NaN entry of the tensor is exactly 0.0 or 1.0.

◆ is_constant()

template<typename T>
bool opennn::is_constant ( const T & tensor)
inlinenodiscard

Returns true if every non-NaN entry of the tensor equals the first finite entry.

◆ is_contiguous()

bool opennn::is_contiguous ( const vector< Index > & indices)
inlinenodiscard

Returns true if the sorted indices form a contiguous run (each entry equals the previous plus one).

◆ is_cpu()

bool opennn::is_cpu ( )
inlinenodiscard

Returns true when the resolved configuration runs on CPU.

◆ is_date_time_string()

bool opennn::is_date_time_string ( string_view )
nodiscard

Returns true if the string matches one of the supported date/time formats.

◆ is_gpu()

bool opennn::is_gpu ( )
inlinenodiscard

Returns true when the resolved configuration runs on a CUDA GPU.

◆ is_numeric_string()

bool opennn::is_numeric_string ( string_view )
nodiscard

Returns true if the string can be parsed as a numeric literal.

◆ l1_regularization()

void opennn::l1_regularization ( const TensorView & parameters,
float lambda,
float & penalty )

Computes the L1 regularization penalty lambda * sum(|parameters|).

◆ l1_regularization_gradient()

void opennn::l1_regularization_gradient ( const TensorView & parameters,
float lambda,
const TensorView & gradient )

Adds the L1 regularization gradient lambda * sign(parameters) into the gradient tensor.

◆ l2_regularization()

void opennn::l2_regularization ( const TensorView & parameters,
float lambda,
float & penalty )

Computes the L2 regularization penalty lambda * sum(parameters^2).

◆ l2_regularization_gradient()

void opennn::l2_regularization_gradient ( const TensorView & parameters,
float lambda,
const TensorView & gradient )

Adds the L2 regularization gradient 2 * lambda * parameters into the gradient tensor.

◆ layer_type_map()

const EnumMap< LayerType > & opennn::layer_type_map ( )
inlinenodiscard

Returns the bidirectional mapping between LayerType values and their string names.

◆ layer_type_to_string()

const string & opennn::layer_type_to_string ( LayerType type)
inlinenodiscard

Returns the string name associated with the given LayerType.

◆ linear_correlation()

Correlation opennn::linear_correlation ( const VectorR & ,
const VectorR &  )
nodiscard

Pearson linear correlation between two equal-length vectors.

Parameters
xFirst variable.
ySecond variable.
Returns
Correlation with intercept a, slope b, and coefficient r.

◆ linear_correlation_spearman()

Correlation opennn::linear_correlation_spearman ( const VectorR & ,
const VectorR &  )
nodiscard

Spearman rank correlation between two vectors using a linear fit on ranks.

◆ load_image() [1/2]

Tensor3 opennn::load_image ( const filesystem::path & )

Loads an image from disk into a rank-3 (height, width, channels) tensor.

◆ load_image() [2/2]

void opennn::load_image ( const filesystem::path & ,
float * dst,
Index expected_height,
Index expected_width,
Index expected_channels,
bool divide_by_255 = false )

Loads an image into a pre-allocated float buffer at the given shape.

Parameters
pathImage file on disk.
dstDestination buffer with capacity expected_height * expected_width * expected_channels.
expected_heightRequired output height (image is resized if it differs).
expected_widthRequired output width.
expected_channelsRequired number of channels.
divide_by_255Divide pixel values by 255 to produce a [0, 1] range.

◆ load_json_file()

JsonDocument opennn::load_json_file ( const filesystem::path & file_name)
nodiscard

◆ logarithmic_correlation()

Correlation opennn::logarithmic_correlation ( const VectorR & ,
const VectorR &  )
nodiscard

Logarithmic correlation: fits y = a + b * log(x) and returns the resulting fit.

◆ logistic_correlation() [1/4]

Correlation opennn::logistic_correlation ( const MatrixR & ,
const MatrixR &  )
nodiscard

Logistic correlation between two one-hot matrices.

◆ logistic_correlation() [2/4]

Correlation opennn::logistic_correlation ( const MatrixR & ,
const VectorR &  )
nodiscard

Logistic correlation between a one-hot matrix predictor and a vector target.

◆ logistic_correlation() [3/4]

Correlation opennn::logistic_correlation ( const VectorR & ,
const MatrixR &  )
nodiscard

Logistic correlation between a vector predictor and a one-hot matrix target.

◆ logistic_correlation() [4/4]

Correlation opennn::logistic_correlation ( const VectorR & ,
const VectorR &  )
nodiscard

Logistic correlation between two vectors (binary or continuous targets).

◆ logistic_correlation_spearman()

Correlation opennn::logistic_correlation_spearman ( const VectorR & ,
const VectorR &  )
nodiscard

Spearman-rank logistic correlation between two vectors.

◆ max_pooling_3d_backward()

void opennn::max_pooling_3d_backward ( const TensorView & maximal_indices,
const TensorView & output_delta,
TensorView & input_delta )

Backward pass for 3D max pooling; routes gradients to argmax positions.

◆ max_pooling_3d_backward_cpu()

void opennn::max_pooling_3d_backward_cpu ( const TensorView & maximal_indices,
const TensorView & output_delta,
TensorView & input_delta )

CPU implementation of max_pooling_3d_backward().

◆ max_pooling_3d_forward()

void opennn::max_pooling_3d_forward ( const TensorView & input,
TensorView & output,
TensorView & maximal_indices,
bool is_training )

Forward pass of 3D max pooling; records argmax positions when training.

Parameters
inputSource activations.
outputPooled output activations.
maximal_indicesPositions of the maxima within each pooling window.
is_trainingIf true, populates maximal_indices for use by the backward pass.

◆ max_pooling_3d_forward_cpu()

void opennn::max_pooling_3d_forward_cpu ( const TensorView & input,
TensorView & output,
TensorView & maximal_indices,
bool is_training )

CPU implementation of max_pooling_3d_forward().

◆ maximal_index()

Index opennn::maximal_index ( const VectorR & )
nodiscard

Index of the largest element in a vector.

◆ maximal_indices() [1/2]

VectorI opennn::maximal_indices ( const MatrixR & )
nodiscard

Row/column coordinates of the largest element of a matrix.

◆ maximal_indices() [2/2]

VectorI opennn::maximal_indices ( const VectorR & ,
Index  )
nodiscard

Indices of the n largest elements of a vector.

◆ maximum() [1/3]

float opennn::maximum ( const MatrixR & )
nodiscard

Returns the largest finite element of a matrix.

◆ maximum() [2/3]

float opennn::maximum ( const VectorR & )
nodiscard

Returns the largest finite element of a vector.

◆ maximum() [3/3]

float opennn::maximum ( const VectorR & ,
const vector< Index > &  )
nodiscard

Returns the largest finite element of the selected rows of a vector.

◆ mean() [1/4]

VectorR opennn::mean ( const MatrixR & )
nodiscard

Column-wise arithmetic means of a matrix.

◆ mean() [2/4]

VectorR opennn::mean ( const MatrixR & ,
const vector< Index > & ,
const vector< Index > &  )
nodiscard

Column-wise means of a matrix restricted to the given rows and columns.

◆ mean() [3/4]

float opennn::mean ( const MatrixR & ,
Index  )
nodiscard

Arithmetic mean of a matrix column, ignoring NaNs.

◆ mean() [4/4]

float opennn::mean ( const VectorR & )
nodiscard

Arithmetic mean of a vector, ignoring NaNs.

◆ mean_squared_error()

void opennn::mean_squared_error ( const TensorView & input,
const TensorView & target,
float & error,
float * workspace_device )

Computes the mean squared error between predictions and targets.

Parameters
inputPredicted values.
targetGround-truth targets with the same shape as input.
errorOutput scalar holding the resulting MSE.
workspace_deviceOptional device-side reduction workspace (ignored on CPU).

◆ mean_squared_error_gradient()

void opennn::mean_squared_error_gradient ( const TensorView & input,
const TensorView & target,
const TensorView & input_delta )

Writes the MSE gradient with respect to the predictions into input_delta.

Parameters
inputPredicted values.
targetGround-truth targets.
input_deltaOutput gradient tensor with the same shape as input.

◆ median() [1/5]

VectorR opennn::median ( const MatrixR & )
nodiscard

Column-wise medians of a matrix.

◆ median() [2/5]

VectorR opennn::median ( const MatrixR & ,
const vector< Index > &  )
nodiscard

Column-wise medians of the selected columns.

◆ median() [3/5]

VectorR opennn::median ( const MatrixR & ,
const vector< Index > & ,
const vector< Index > &  )
nodiscard

Column-wise medians restricted to the given rows and columns.

◆ median() [4/5]

float opennn::median ( const MatrixR & ,
Index  )
nodiscard

Median of a single matrix column.

◆ median() [5/5]

float opennn::median ( const VectorR & )
nodiscard

Median of a vector.

◆ merge_heads()

void opennn::merge_heads ( const TensorView & source,
TensorView & destination )

Inverse of split_heads(); merges per-head tensors back into a single representation.

◆ merge_heads_cpu()

void opennn::merge_heads_cpu ( const TensorView & source,
TensorView & destination )

CPU implementation of merge_heads().

◆ minimal_index()

Index opennn::minimal_index ( const VectorR & )
nodiscard

Index of the smallest element in a vector.

◆ minimal_indices() [1/2]

VectorI opennn::minimal_indices ( const MatrixR & )
nodiscard

Row/column coordinates of the smallest element of a matrix.

◆ minimal_indices() [2/2]

VectorI opennn::minimal_indices ( const VectorR & ,
Index  )
nodiscard

Indices of the n smallest elements of a vector.

◆ minimum() [1/3]

float opennn::minimum ( const MatrixR & )
nodiscard

Returns the smallest finite element of a matrix.

◆ minimum() [2/3]

float opennn::minimum ( const VectorR & )
nodiscard

Returns the smallest finite element of a vector.

◆ minimum() [3/3]

float opennn::minimum ( const VectorR & ,
const vector< Index > &  )
nodiscard

Returns the smallest finite element of the selected rows of a vector.

◆ minkowski_error()

void opennn::minkowski_error ( const TensorView & input,
const TensorView & target,
float power,
float & error,
float * workspace_device )

Computes the Minkowski error sum(|input - target|^power) for the given power exponent.

◆ minkowski_error_gradient()

void opennn::minkowski_error_gradient ( const TensorView & input,
const TensorView & target,
float power,
const TensorView & input_delta )

Writes the Minkowski-error gradient with respect to the predictions into input_delta.

◆ multiply()

void opennn::multiply ( const TensorView & input_a,
bool transpose_a,
const TensorView & input_b,
bool transpose_b,
TensorView & output,
float alpha = 1.0f,
float beta = 0.0f )

General matrix multiply: output = alpha * op(input_a) * op(input_b) + beta * output.

Parameters
input_aLeft operand.
transpose_aTranspose input_a before multiplying.
input_bRight operand.
transpose_bTranspose input_b before multiplying.
outputDestination tensor (also read when beta != 0).
alphaScale factor applied to the matrix product.
betaScale factor applied to the existing output.

◆ multiply_cpu()

void opennn::multiply_cpu ( const TensorView & input_a,
bool transpose_a,
const TensorView & input_b,
bool transpose_b,
TensorView & output,
float alpha = 1.0f,
float beta = 0.0f )

CPU implementation of multiply().

◆ normalized_squared_error()

void opennn::normalized_squared_error ( const TensorView & input,
const TensorView & target,
float coefficient,
float & error,
float * workspace_device )

Computes the squared error normalized by a dataset-level coefficient.

Parameters
inputPredicted values.
targetGround-truth targets.
coefficientNormalization coefficient (typically the target variance).
errorOutput scalar holding the normalized squared error.
workspace_deviceOptional device-side reduction workspace.

◆ normalized_squared_error_gradient()

void opennn::normalized_squared_error_gradient ( const TensorView & input,
const TensorView & target,
float coefficient,
const TensorView & input_delta )

Writes the normalized-squared-error gradient with respect to the predictions into input_delta.

◆ operator<<()

template<typename T>
ostream & opennn::operator<< ( ostream & os,
const vector< T > & vec )

◆ pad()

void opennn::pad ( const TensorView & input,
TensorView & output )

Pads the input tensor and writes the result into output.

◆ perform_Householder_QR_decomposition()

VectorR opennn::perform_Householder_QR_decomposition ( const MatrixR & ,
const VectorR &  )
nodiscard

Solves a linear least-squares problem via Householder QR decomposition.

◆ point_biserial_correlation()

Correlation opennn::point_biserial_correlation ( const VectorR & ,
const VectorR &  )
nodiscard

Point-biserial correlation between a binary vector and a continuous vector.

◆ pooling_method_to_string()

const string & opennn::pooling_method_to_string ( PoolingMethod method)
inline

◆ power_correlation()

Correlation opennn::power_correlation ( const VectorR & ,
const VectorR &  )
nodiscard

Power correlation: fits y = a * x^b and returns the resulting fit.

◆ quartiles() [1/2]

VectorR opennn::quartiles ( const VectorR & )
nodiscard

Returns [Q1, Q2, Q3] of a vector.

◆ quartiles() [2/2]

VectorR opennn::quartiles ( const VectorR & ,
const vector< Index > &  )
nodiscard

Returns [Q1, Q2, Q3] of the selected entries of a vector.

◆ r_correlation_to_z_correlation()

float opennn::r_correlation_to_z_correlation ( const float )
nodiscard

Fisher r-to-z transform of a correlation coefficient.

◆ random_bool()

bool opennn::random_bool ( float = 0.5)
nodiscard

Draws a boolean that is true with the given probability.

◆ random_integer()

Index opennn::random_integer ( Index ,
Index  )
nodiscard

Draws an integer uniformly in [min, max].

◆ random_uniform()

float opennn::random_uniform ( float = -1,
float = 1 )
nodiscard

Draws a float uniformly in [min, max].

◆ range()

float opennn::range ( const VectorR & )
nodiscard

Returns the maximum minus the minimum of a vector.

◆ read_json_bool()

bool opennn::read_json_bool ( const Json * root,
const string & field )
nodiscard

◆ read_json_index()

long opennn::read_json_index ( const Json * root,
const string & field )
nodiscard

◆ read_json_string()

string opennn::read_json_string ( const Json * root,
const string & field )
nodiscard

◆ read_json_string_fallback()

string opennn::read_json_string_fallback ( const Json * root,
initializer_list< string > names )
nodiscard

◆ read_json_type()

float opennn::read_json_type ( const Json * root,
const string & field )
nodiscard

◆ reflect_image_horizontal()

void opennn::reflect_image_horizontal ( Tensor3 & )

Mirrors the image horizontally (left-right) in place.

◆ reflect_image_vertical()

void opennn::reflect_image_vertical ( Tensor3 & )

Mirrors the image vertically (top-bottom) in place.

◆ register_classes()

void opennn::register_classes ( )

◆ replace()

void opennn::replace ( string & ,
const string & ,
const string &  )

In-place replacement of every occurrence of a substring with another.

◆ replace_all_appearances()

void opennn::replace_all_appearances ( string & ,
const string & ,
const string &  )

Replaces every occurrence of a substring with another, in place.

◆ replace_all_word_appearances()

void opennn::replace_all_word_appearances ( string & ,
const string & ,
const string &  )

Replaces every whole-word occurrence of a token with another, in place.

◆ require_json_field()

const Json * opennn::require_json_field ( const Json * root,
const string & field )
nodiscard

◆ resize_image()

Tensor3 opennn::resize_image ( const Tensor3 & ,
Index ,
Index  )

Returns a resized copy of an image at the requested height and width.

◆ role_matches()

bool opennn::role_matches ( VariableRole actual,
VariableRole query )
inline

Returns true if actual satisfies query, treating InputTarget as Input or Target.

◆ rotate_image()

void opennn::rotate_image ( const Tensor3 & ,
Tensor3 & ,
float  )

Rotates the image by the given angle (radians) into the destination tensor.

◆ round_to_precision()

float opennn::round_to_precision ( float ,
const int &  )

Rounds the given floating point value to the requested number of significant digits.

◆ row_finite() [1/2]

bool opennn::row_finite ( const MatrixR & matrix,
Index i )
inlinenodiscard

Returns true if every entry in row i of the matrix is finite.

◆ row_finite() [2/2]

bool opennn::row_finite ( const VectorR & values,
Index i )
inlinenodiscard

Returns true if the i-th entry of the vector is finite.

◆ sample_role_map()

const EnumMap< SampleRole > & opennn::sample_role_map ( )
inlinenodiscard

Returns the bidirectional string/enum map for SampleRole.

◆ sample_role_to_string()

const string & opennn::sample_role_to_string ( SampleRole role)
inlinenodiscard

Returns the canonical string name for a SampleRole.

◆ scale()

void opennn::scale ( const TensorView & input,
const TensorView & minimums,
const TensorView & maximums,
const TensorView & means,
const TensorView & standard_deviations,
const TensorView & scalers,
float min_range,
float max_range,
TensorView & output )

Applies per-feature scaling (mean/std, min/max, or other scalers) to a tensor.

Parameters
inputSource tensor.
minimumsColumn-wise minimums used for min-max scaling.
maximumsColumn-wise maximums used for min-max scaling.
meansColumn-wise means used for standardisation.
standard_deviationsColumn-wise standard deviations.
scalersPer-column scaler kind selector.
min_rangeLower bound of the target range for min-max scaling.
max_rangeUpper bound of the target range for min-max scaling.
outputDestination tensor for the scaled values.

◆ scale_cpu()

void opennn::scale_cpu ( const TensorView & input,
const TensorView & minimums,
const TensorView & maximums,
const TensorView & means,
const TensorView & standard_deviations,
const TensorView & scalers,
float min_range,
float max_range,
TensorView & output )

CPU implementation of scale().

◆ scale_logarithmic()

void opennn::scale_logarithmic ( MatrixMap ,
Index  )

Applies an element-wise logarithm to the given column.

◆ scale_mean_standard_deviation()

void opennn::scale_mean_standard_deviation ( MatrixMap ,
Index ,
const Descriptives &  )

Standardises a column of the matrix in place using its descriptives' mean and standard deviation.

Parameters
matrixData matrix to modify in place.
columnColumn index to scale.
descriptivesPre-computed descriptives of the column.

◆ scale_minimum_maximum()

void opennn::scale_minimum_maximum ( MatrixMap ,
Index ,
const Descriptives & ,
float = -1.0f,
float = 1.0f )

Rescales a column to the [min_range, max_range] interval using its descriptives.

◆ scale_standard_deviation()

void opennn::scale_standard_deviation ( MatrixMap ,
Index ,
const Descriptives &  )

Divides a column of the matrix by its standard deviation in place.

◆ scaler_method_map()

const EnumMap< ScalerMethod > & opennn::scaler_method_map ( )
inline

Returns the bidirectional string/enum map for ScalerMethod.

◆ scaler_method_to_string()

const string & opennn::scaler_method_to_string ( ScalerMethod method)
inline

Returns the canonical string name for a ScalerMethod.

◆ set_random_integer()

void opennn::set_random_integer ( MatrixR & ,
Index ,
Index  )

Fills the matrix with uniform random integers in [min, max].

◆ set_random_normal()

void opennn::set_random_normal ( MatrixMap ,
float = 0,
float = 1 )

Fills the matrix with normal random values of the given mean and standard deviation.

◆ set_random_uniform() [1/2]

void opennn::set_random_uniform ( MatrixR & ,
float = -0.1,
float = 0.1 )

Fills the matrix with uniform random values in [min, max].

◆ set_random_uniform() [2/2]

void opennn::set_random_uniform ( VectorMap ,
float = -0.1,
float = 0.1 )

Fills the vector map with uniform random values in [min, max].

◆ set_seed()

void opennn::set_seed ( unsigned seed)

Seeds the library-wide pseudo-random number generator.

◆ shape_to_string()

string opennn::shape_to_string ( const Shape & ,
const string & = " " )
nodiscard

Serializes a shape as a separator-joined string of dimensions.

◆ shuffle()

void opennn::shuffle ( VectorB & vector_to_shuffle)

Randomly permutes the entries of a boolean vector in place.

◆ shuffle_vector()

template<typename T>
void opennn::shuffle_vector ( vector< T > & )

Randomly permutes the entries of the given vector in place.

◆ shuffle_vector_blocks()

void opennn::shuffle_vector_blocks ( vector< Index > & ,
size_t = 20 )

Shuffles contiguous blocks of the given length while preserving in-block order.

◆ slice_rows() [1/2]

MatrixR opennn::slice_rows ( const MatrixR & matrix,
const vector< Index > & indices )
inlinenodiscard

Returns a copy of the matrix containing only the rows at the given indices.

◆ slice_rows() [2/2]

VectorR opennn::slice_rows ( const VectorR & values,
const vector< Index > & indices )
inlinenodiscard

Returns a copy of the vector containing only the entries at the given indices.

◆ softmax()

void opennn::softmax ( TensorView & output)

Applies softmax in place along the trailing dimension of output.

◆ softmax_cpu()

void opennn::softmax_cpu ( TensorView & output)

CPU implementation of softmax().

◆ sort_string_vector()

void opennn::sort_string_vector ( vector< string > & )

Sorts a vector of strings in place in ascending lexicographical order.

◆ split_heads()

void opennn::split_heads ( const TensorView & source,
TensorView & destination )

Reshapes a multi-head attention tensor by splitting the last axis into heads.

◆ split_heads_cpu()

void opennn::split_heads_cpu ( const TensorView & source,
TensorView & destination )

CPU implementation of split_heads().

◆ standard_deviation() [1/2]

float opennn::standard_deviation ( const VectorR & )
nodiscard

Sample standard deviation of a vector.

◆ standard_deviation() [2/2]

VectorR opennn::standard_deviation ( const VectorR & ,
Index  )
nodiscard

Rolling standard deviation of a vector over a window of the given size.

◆ string_to_layer_type()

LayerType opennn::string_to_layer_type ( const string & name)
inlinenodiscard

Returns the LayerType corresponding to the given string name.

◆ string_to_pooling_method()

PoolingMethod opennn::string_to_pooling_method ( const string & name)
inline

◆ string_to_sample_role()

SampleRole opennn::string_to_sample_role ( const string & name)
inlinenodiscard

Parses a string (name or "0"/"1"/"2"/"3") into the matching SampleRole.

◆ string_to_scaler_method()

ScalerMethod opennn::string_to_scaler_method ( const string & name)
inline

Parses a string into the matching ScalerMethod enumerator.

◆ string_to_shape()

Shape opennn::string_to_shape ( const string & ,
const string & = " " )
nodiscard

Parses a separator-joined string of dimensions into a Shape.

◆ string_to_tensor()

template<typename T, size_t Rank>
void opennn::string_to_tensor ( const string & input,
TensorR< Rank > & values )

Parses a whitespace-separated string into the flat storage of a tensor.

◆ string_to_variable_role()

VariableRole opennn::string_to_variable_role ( const string & name)
inline

Parses a string into a VariableRole; "Id" is mapped to VariableRole::None.

◆ string_to_variable_type()

VariableType opennn::string_to_variable_type ( const string & name)
inline

Parses a string into the matching VariableType enumerator.

◆ string_to_vector()

void opennn::string_to_vector ( const string & input,
VectorR & values )

Parses a whitespace-separated string of floats into a VectorR.

◆ tensor_to_string()

template<typename T, size_t Rank>
string opennn::tensor_to_string ( const TensorR< Rank > & values,
const string & separator = " " )
nodiscard

Serializes a tensor's flat data to a string with the given separator.

◆ throw_if()

void opennn::throw_if ( bool condition,
const string & message,
const source_location & loc = source_location::current() )
inline

◆ to_cuda()

cudaDataType_t opennn::to_cuda ( Type type)
inlinenodiscardnoexcept

Returns the CUDA data type matching the given OpenNN Type (Auto resolves to FP32).

◆ to_cudnn()

cudnnDataType_t opennn::to_cudnn ( Type type)
inlinenodiscardnoexcept

Returns the cuDNN data type matching the given OpenNN Type (Auto resolves to FP32).

◆ to_int()

int opennn::to_int ( Index value)
inlinenodiscard

◆ to_type()

float opennn::to_type ( Index value)
inlinenodiscard

◆ tokenize()

vector< string > opennn::tokenize ( const string & )
nodiscard

Splits the input on whitespace into individual tokens.

◆ tokenize_views()

vector< string_view > opennn::tokenize_views ( string_view )
nodiscard

Whitespace-tokenises a string view, returning views into the source buffer.

◆ total_frequencies()

VectorI opennn::total_frequencies ( const vector< Histogram > & )
nodiscard

Sums the per-bin frequencies across a collection of histograms.

◆ translate_image_x()

void opennn::translate_image_x ( const Tensor3 & ,
Tensor3 & ,
Index  )

Translates the image along the X axis by the given number of pixels.

◆ translate_image_y()

void opennn::translate_image_y ( const Tensor3 & ,
Tensor3 & ,
Index  )

Translates the image along the Y axis by the given number of pixels.

◆ trim_view()

string_view opennn::trim_view ( string_view )
nodiscard

Returns a view onto the input with leading and trailing whitespace removed.

◆ type_bytes()

Index opennn::type_bytes ( Type type)
inlinenodiscardnoexcept

Returns the byte size of one element of the given OpenNN Type.

◆ unscale()

void opennn::unscale ( const TensorView & input,
const TensorView & minimums,
const TensorView & maximums,
const TensorView & means,
const TensorView & standard_deviations,
const TensorView & scalers,
float min_range,
float max_range,
TensorView & output )

Inverse of scale(); reconstructs original values from a previously scaled tensor.

◆ unscale_cpu()

void opennn::unscale_cpu ( const TensorView & input,
const TensorView & minimums,
const TensorView & maximums,
const TensorView & means,
const TensorView & standard_deviations,
const TensorView & scalers,
float min_range,
float max_range,
TensorView & output )

CPU implementation of unscale().

◆ unscale_image_minimum_maximum()

void opennn::unscale_image_minimum_maximum ( MatrixMap ,
Index  )

Maps a column back from [-1, 1] to the [0, 255] image-pixel range.

◆ unscale_logarithmic()

void opennn::unscale_logarithmic ( MatrixMap ,
Index  )

Inverse of scale_logarithmic() for the given column.

◆ unscale_mean_standard_deviation()

void opennn::unscale_mean_standard_deviation ( MatrixMap ,
Index ,
const Descriptives &  )

Inverse of scale_mean_standard_deviation() for the given column.

◆ unscale_minimum_maximum()

void opennn::unscale_minimum_maximum ( MatrixMap ,
Index ,
const Descriptives & ,
float = -1.0f,
float = 1.0f )

Inverse of scale_minimum_maximum(): reconstructs original values for the given column.

◆ unscale_standard_deviation()

void opennn::unscale_standard_deviation ( MatrixMap ,
Index ,
const Descriptives &  )

Inverse of scale_standard_deviation() for the given column.

◆ variable_role_map()

const EnumMap< VariableRole > & opennn::variable_role_map ( )
inline

Returns the bidirectional string/enum map for VariableRole.

◆ variable_role_to_string()

const string & opennn::variable_role_to_string ( VariableRole role)
inline

Returns the canonical string name for a VariableRole.

◆ variable_type_map()

const EnumMap< VariableType > & opennn::variable_type_map ( )
inline

Returns the bidirectional string/enum map for VariableType.

◆ variable_type_to_string()

const string & opennn::variable_type_to_string ( VariableType type)
inline

Returns the canonical string name for a VariableType.

◆ variance() [1/2]

float opennn::variance ( const VectorR & )
nodiscard

Sample variance of a vector.

◆ variance() [2/2]

float opennn::variance ( const VectorR & ,
const VectorI &  )
nodiscard

Sample variance of the selected entries of a vector.

◆ vector_descriptives()

Descriptives opennn::vector_descriptives ( const VectorR & )
nodiscard

Returns the (min, max, mean, std) descriptives of a vector.

◆ vector_map()

VectorMap opennn::vector_map ( const MatrixR & ,
Index  )
nodiscard

Returns an Eigen VectorMap that views a single column of a matrix without copying.

◆ vector_to_string() [1/2]

template<typename Derived>
string opennn::vector_to_string ( const Eigen::DenseBase< Derived > & values,
const string & separator = " " )
inlinenodiscard

Serializes an Eigen dense expression to a string with the given separator.

◆ vector_to_string() [2/2]

template<typename T>
string opennn::vector_to_string ( const vector< T > & values,
const string & separator = " " )
nodiscard

Serializes a vector to a string with the given element separator.

◆ view_at_slot_or() [1/2]

TensorView & opennn::view_at_slot_or ( vector< TensorView > & views,
const vector< size_t > & slots,
size_t i,
TensorView & fallback )
inline

◆ view_at_slot_or() [2/2]

TensorView & opennn::view_at_slot_or ( vector< vector< TensorView > > & views,
const vector< size_t > & slots,
size_t i,
TensorView & fallback )
inline

◆ visit_type()

template<Type... Supported, typename F>
void opennn::visit_type ( Type t,
F && f )

Dispatches f with the TypeInfo of the runtime Type t (must be in Supported).

Parameters
tRuntime numeric type to resolve.
fCallable invoked with the matching TypeInfo as its only argument.

◆ visit_type_pair()

template<Type... Supported, typename F>
void opennn::visit_type_pair ( Type t_in,
Type t_out,
F && f )

Dispatches f with the TypeInfo pair for an input and output runtime Type.

Parameters
t_inRuntime numeric type for inputs.
t_outRuntime numeric type for outputs.
fCallable invoked with (in_info, out_info).

◆ weighted_squared_error()

void opennn::weighted_squared_error ( const TensorView & input,
const TensorView & target,
float pos_w,
float neg_w,
float & error,
float * workspace_device )

Computes the binary squared error weighted asymmetrically for positive and negative classes.

Parameters
inputPredicted probabilities in [0,1].
targetBinary targets (0 or 1).
pos_wWeight applied to positive samples.
neg_wWeight applied to negative samples.
errorOutput scalar holding the weighted squared error.
workspace_deviceOptional device-side reduction workspace.

◆ weighted_squared_error_gradient()

void opennn::weighted_squared_error_gradient ( const TensorView & input,
const TensorView & target,
float pos_w,
float neg_w,
float coefficient,
const TensorView & input_delta )

Writes the gradient of the weighted squared error scaled by coefficient into input_delta.

◆ write_json()

void opennn::write_json ( JsonWriter & writer,
initializer_list< pair< const char *, string > > props )

◆ z_correlation_to_r_correlation()

float opennn::z_correlation_to_r_correlation ( const float )
nodiscard

Inverse Fisher z-to-r transform.

Variable Documentation

◆ ALIGN_BYTES

Index opennn::ALIGN_BYTES = EIGEN_MAX_ALIGN_BYTES
staticconstexpr

◆ ALIGN_ELEMENTS

Index opennn::ALIGN_ELEMENTS = ALIGN_BYTES / sizeof(float)
staticconstexpr

◆ CUBLAS_COMPUTE_DTYPE

cublasComputeType_t opennn::CUBLAS_COMPUTE_DTYPE = CUBLAS_COMPUTE_32F_FAST_TF32
constexpr

◆ CUDA_REDUCTION_DTYPE

cudaDataType_t opennn::CUDA_REDUCTION_DTYPE = CUDA_R_32F
constexpr

◆ EPSILON

float opennn::EPSILON = numeric_limits<float>::epsilon()
constexpr

◆ GRADIENT_NORM_EPS

float opennn::GRADIENT_NORM_EPS = 1e-6f
inlineconstexpr

◆ MAX

float opennn::MAX = numeric_limits<float>::max()
constexpr

◆ NEG_INFINITY

float opennn::NEG_INFINITY = -numeric_limits<float>::infinity()
constexpr

◆ QUIET_NAN

float opennn::QUIET_NAN = numeric_limits<float>::quiet_NaN()
constexpr

◆ SOFTMAX_MASK_VALUE

float opennn::SOFTMAX_MASK_VALUE = float(-1e9f)
constexpr