dlupdate — Apply a function handle across matching Deep Learning parameter trees.
dlupdate(fun,args...) recursively applies a function handle to matching leaves in one or more parameter trees and reconstructs the output tree shape.
Syntax
out = dlupdate(fun, args...)How dlupdate works
- The first argument must be a function handle, bound function handle, method function handle, external function handle, or closure.
- Struct fields and cell elements are traversed recursively; matching inputs must have the same container shape and field names.
- Structs, tables, and timetables that look like Deep Learning learnables containers with
Layer,Parameter, andValueentries preserveLayerandParametermetadata and apply the callback only to entries inValue. dlarraycompatibility objects are treated as leaf parameter values, so callbacks can preserve or replace the wrapper intentionally.- The requested output count is forwarded to the callback for each leaf, and each callback output is reconstructed as its own output tree.
dlnetworkobjects are traversed through theirLearnablesmetadata and rebuilt with updated fully-connected layer weights and bias. Arbitrary custom model objects remain unsupported.
GPU memory and residency
dlupdate itself is a tree traversal and callback-dispatch helper and does not gather parameter trees before callback dispatch. GPU residency is preserved when the callback accepts and returns provider-resident values; model-wide provider kernels remain tracked by the queued GPU fast-path audit.
Example
Update Struct Parameters
net = dlupdate(@plus, net, gradients)Expected output:
A dlnetwork, struct, cell, table, or dlarray-compatible tree with updated leaves.Using dlupdate with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how dlupdate changes the result.
Run a small dlupdate 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 · eluLayer · exportONNXNetwork · featureInputLayer · forward · fullyConnectedLayer · globalAveragePooling1dLayer · layerGraph · layerNormalizationLayer · lstmLayer · padsequences · regressionLayer · reluLayer · sequenceInputLayer · softmaxLayer · trainingOptions · trainnet · trainNetwork
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.