forward — Run a supported dlnetwork forward pass.
forward(net,X) evaluates a RunMat dlnetwork compatibility object over numeric predictor data.
Syntax
Y = forward(net, X)How forward works
- Supports sequential feed-forward networks made from
featureInputLayer,fullyConnectedLayer,reluLayer,eluLayer,softmaxLayer,classificationLayer, andregressionLayer. - Numeric matrix inputs are interpreted as observations in rows and predictors in columns.
dlarrayinputs are unwrapped for normal execution, and the output is wrapped back into adlarraypreserving the input format metadata.- Inside
dlfeval, hostdlarrayinputs and supported dlnetwork learnables are traced through fully-connected, ReLU, ELU, and softmax layers so scalar losses can be differentiated bydlgradient. - Name-value execution options, recurrent state outputs, branching DAG execution, custom layers, GPU-backed dlarray execution, and provider-resident autodiff are not implemented in this slice and raise explicit compatibility errors.
GPU memory and residency
forward currently gathers plain provider-resident gpuArray inputs to host before evaluating the supported layer chain outside autodiff. GPU-backed dlarray inputs are rejected before gather because native Deep Learning provider execution and tape kernels remain future acceleration work.
Example
Evaluate a feed-forward dlnetwork
layers = {featureInputLayer(2,'Name','in'); fullyConnectedLayer(2,'Name','fc'); softmaxLayer('Name','prob')};
net = dlnetwork(layers);
y = forward(net, [1 2; 3 4])Expected output:
y is a numeric matrix with one row per observation.Using forward with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how forward changes the result.
Run a small forward example, explain the result, then change one input and compare the output.
Related Deep Learning functions
adamupdate · analyzeNetwork · bilstmLayer · classificationLayer · combvec · convolution1dLayer · crossentropy · dlarray · dlfeval · dlgradient · dlnetwork · dlupdate · eluLayer · exportONNXNetwork · featureInputLayer · fullyConnectedLayer · globalAveragePooling1dLayer · layerGraph · layerNormalizationLayer · lstmLayer · padsequences · regressionLayer · reluLayer · sequenceInputLayer · softmaxLayer · trainingOptions · trainnet · trainNetwork
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how forward is executed, line by line, in Rust.
- View the source for forward in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.