NetExtract
✖
NetExtract
extracts the layer identified by lspec from within the NetGraph or NetChain object net.
extracts the value of the parameter param from the layer identified by lspec in net.
extracts the value of a parameter for the specified NetEncoder or NetDecoder.
Details

- NetExtract supports the level specification All to indicate that an association should be returned, giving all the layers within a NetGraph or NetChain, or all the properties of net layers, NetEncoder and NetDecoder.
- The layer specification can be an integer indicating the n
layer or a string indicating a named layer.
- Parameter specifications can be the names of any of the arrays or options contained within a layer.
- NetExtract returns Automatic if a learned parameter has not yet been initialized, or an unlearned parameter has not yet been inferred.
- NetExtract[net,{spec1,spec2,…}] is equivalent to net[[spec1,spec2,…]] when the speci are not lists.
- For NetChain, NetGraph, NetEncoder, NetDecoder and layers, Normal[net] is equivalent to NetExtract[net,All].
Examples
open allclose allBasic Examples (4)Summary of the most common use cases
Create a randomly initialized layer:

https://wolfram.com/xid/09b76y1yu-9ssm5w

Extract the weight matrix from the layer:

https://wolfram.com/xid/09b76y1yu-pdsy1g

Create a NetChain:

https://wolfram.com/xid/09b76y1yu-4ua969


https://wolfram.com/xid/09b76y1yu-6k85k2

Create an operator containing a net:

https://wolfram.com/xid/09b76y1yu-k1yqh5

Extract the net from inside the operator:

https://wolfram.com/xid/09b76y1yu-ku69ik

Create a NetEncoder:

https://wolfram.com/xid/09b76y1yu-ia0zu2


https://wolfram.com/xid/09b76y1yu-orshax

Extract the output dimensions of the encoder:

https://wolfram.com/xid/09b76y1yu-5nsnp0

Extract the color space of the encoder:

https://wolfram.com/xid/09b76y1yu-yx3e76

Scope (6)Survey of the scope of standard use cases
Create a NetChain with named layers:

https://wolfram.com/xid/09b76y1yu-cw74k6


https://wolfram.com/xid/09b76y1yu-1w3xzi


https://wolfram.com/xid/09b76y1yu-kcw2fa


https://wolfram.com/xid/09b76y1yu-20etny

Extract the function used in the elementwise layer:

https://wolfram.com/xid/09b76y1yu-rcvq3e


https://wolfram.com/xid/09b76y1yu-tnaqoh


https://wolfram.com/xid/09b76y1yu-guswql

Create an initialized NetChain:

https://wolfram.com/xid/09b76y1yu-mhy5aa

Extract the weights from a specific layer:

https://wolfram.com/xid/09b76y1yu-du54xa

Extract the weights from all layers:

https://wolfram.com/xid/09b76y1yu-gc7tt4

Create a NetGraph object with named layers:

https://wolfram.com/xid/09b76y1yu-si3f3s


https://wolfram.com/xid/09b76y1yu-n70hsg


https://wolfram.com/xid/09b76y1yu-6e3yw7

Create a layer with specific input dimensions:

https://wolfram.com/xid/09b76y1yu-qh5hlf


https://wolfram.com/xid/09b76y1yu-3xndjp

Extract the output dimensions:

https://wolfram.com/xid/09b76y1yu-o9311a

Create a layer with an attached encoder:

https://wolfram.com/xid/09b76y1yu-c6cujl


https://wolfram.com/xid/09b76y1yu-4rx2lm

Extract a parameter of the input encoder:

https://wolfram.com/xid/09b76y1yu-ojf0b0

Extract the type and output dimensions of the input encoder:

https://wolfram.com/xid/09b76y1yu-rrp0ls

Extract the value of all shared arrays in a network:

https://wolfram.com/xid/09b76y1yu-4usjtx


https://wolfram.com/xid/09b76y1yu-oymczd


https://wolfram.com/xid/09b76y1yu-lq5ju

In this example, NetArray["Weights"] corresponds to the value of the weights in all layers:

https://wolfram.com/xid/09b76y1yu-1ffuyc

Properties & Relations (1)Properties of the function, and connections to other functions
The part specifications supported by NetExtract are identical to those used by NetReplacePart.
Possible Issues (1)Common pitfalls and unexpected behavior
Create a ConvolutionLayer:

https://wolfram.com/xid/09b76y1yu-clveiy

Attempting to extract the weights of this uninitialized layer returns Automatic:

https://wolfram.com/xid/09b76y1yu-iuhmje

Known parameters can be extracted:

https://wolfram.com/xid/09b76y1yu-c7ffh6

Wolfram Research (2016), NetExtract, Wolfram Language function, https://reference.wolfram.com/language/ref/NetExtract.html (updated 2020).
Text
Wolfram Research (2016), NetExtract, Wolfram Language function, https://reference.wolfram.com/language/ref/NetExtract.html (updated 2020).
Wolfram Research (2016), NetExtract, Wolfram Language function, https://reference.wolfram.com/language/ref/NetExtract.html (updated 2020).
CMS
Wolfram Language. 2016. "NetExtract." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/NetExtract.html.
Wolfram Language. 2016. "NetExtract." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/NetExtract.html.
APA
Wolfram Language. (2016). NetExtract. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetExtract.html
Wolfram Language. (2016). NetExtract. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetExtract.html
BibTeX
@misc{reference.wolfram_2025_netextract, author="Wolfram Research", title="{NetExtract}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/NetExtract.html}", note=[Accessed: 29-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_netextract, organization={Wolfram Research}, title={NetExtract}, year={2020}, url={https://reference.wolfram.com/language/ref/NetExtract.html}, note=[Accessed: 29-March-2025
]}