NetExtract

NetExtract[layer,"param"]

extracts the value of a parameter for the specified net layer.

NetExtract[net,lspec]

extracts the layer identified by lspec from within the NetGraph or NetChain object net.

NetExtract[net,{lspec,"param"}]

extracts the value of the parameter param from the layer identified by lspec in net.

NetExtract[net,{spec1,spec2,}]

extracts a set of elements, where each speci is a list.

Details

  • NetExtract supports the layer specification All to indicate that an association or list should be returned, giving all the layers within a NetGraph or NetChain.
  • The layer specification can be an integer indicating the n^(th) 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,spec] is equivalent to net[[spec]] when spec is not a list of lists.
  • For NetChain and NetGraph objects, Normal[net] is equivalent to NetExtract[net,All].

Examples

open allclose all

Basic Examples  (3)

Create a randomly initialized layer:

In[1]:=
Click for copyable input
Out[1]=

Extract the weight matrix from the layer:

In[2]:=
Click for copyable input
Out[2]=

Create a NetChain:

In[1]:=
Click for copyable input
Out[1]=

Extract the third layer:

In[2]:=
Click for copyable input
Out[2]=

Create an operator containing a net:

In[1]:=
Click for copyable input
Out[1]=

Extract the net from inside the operator:

In[2]:=
Click for copyable input
Out[2]=

Scope  (5)

Possible Issues  (1)

See Also

NetGraph  NetChain  Extract

Introduced in 2016
(11.0)