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:

Wolfram Research (2018), NetDrop, Wolfram Language function, https://reference.wolfram.com/language/ref/NetDrop.html.

Text

Wolfram Research (2018), NetDrop, Wolfram Language function, https://reference.wolfram.com/language/ref/NetDrop.html.

CMS

Wolfram Language. 2018. "NetDrop." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NetDrop.html.

APA

Wolfram Language. (2018). NetDrop. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetDrop.html

BibTeX

@misc{reference.wolfram_2024_netdrop, author="Wolfram Research", title="{NetDrop}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/NetDrop.html}", note=[Accessed: 05-October-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_netdrop, organization={Wolfram Research}, title={NetDrop}, year={2018}, url={https://reference.wolfram.com/language/ref/NetDrop.html}, note=[Accessed: 05-October-2024 ]}