NetDrop

NetDrop[chain,n]

removes the first n layers from a NetChain.

NetDrop[chain,-n]

removes the last n layers from a NetChain.

NetDrop[chain,{start,end}]

drops the layers between start and end in a NetChain.

Details

  • For NetDrop[chain,{start,end}], the start and end can be given as an integer n, which specifies the n^(th) layer, or "name", which specifies a named layer in a NetChain that was constructed using <|"name"->layer,|>.
  • When removing layers from the interior of a NetChain, the input shape of the first removed layer and the output shape of the last removed layer must match.
  • Any NetEncoder or NetDecoder that is present on the chain will be preserved, if possible.
  • NetDrop[net,spec,"port1"->spec1,] can be used to give types for the input and/or output of the resulting NetChain or NetGraph, using the normal type specifications those functions allow. The new port specifications will replace any existing NetEncoder, NetDecoder or type.

Examples

open allclose all

Basic Examples  (2)

Construct a chain consisting of four layers:

Drop layers from the beginning of the chain:

Drop layers from the end of the chain:

Drop layers from the middle of a chain:

Drop layers from the middle of a chain, referring to them by name:

Scope  (1)

Add a new NetDecoder while dropping layers:

Possible Issues  (1)

When removing layers from the interior of a NetChain, the input shape of the first removed layer and the output shape of the last removed layer must match:

Introduced in 2018
 (11.3)