NetFlatten

NetFlatten[net]

collapses nested NetChain and NetGraph objects within net.

NetFlatten[net,n]

collapses up to nesting level n.

Details and Options

Examples

open allclose all

Basic Examples  (2)

Flatten nested chains:

Flatten nested graphs:

Scope  (3)

Turn a NetChain with nested NetGraph into a unique NetGraph:

Collapse nested NetChain and NetGraph up to level 1:

Turn a flat NetGraph into a NetChain:

Properties & Relations  (3)

NetFlatten flattens nested nets, including within operators.

Construct an operator that contains nested chains:

The inner net of the NetMapOperator has been flattened:

NetFlatten yields a NetChain for a NetGraph that is fully flat:

NetFlatten yields a NetGraph for a NetChain that contains a nested NetGraph:

Introduced in 2018
 (11.3)
 |
Updated in 2019
 (12.0)