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, and Value entries preserve Layer and Parameter metadata and apply the callback only to entries in Value.
  • dlarray compatibility 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.
  • dlnetwork objects are traversed through their Learnables metadata 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.

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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.