9
$\begingroup$

I've learned in a recent Virtual Conference that I can use Take to get a subnetwork from a neural network object, so e.g.

net = NetChain[{5, LogisticSigmoid, 6, LogisticSigmoid, 7}];
Take[net,2]

will return a new neural network with only the first two layers of net. Take[net,-2] will get me the last two layers. This seems to be undocumented (at least in Take and in the neural networks overview), but very useful.

So far, I've only found Drop and TakeDrop work on neural nets. Part, Join, Append or Flatten all don't work.

Are there any other useful functions for manipulating networks? For example, adding layers to an existing net (the inverse of Take) or joining two networks (the inverse of TakeDrop) would seem like useful operations. (e.g. to train each layer as an autoencoder, then remove the encoder "backend" and add the next layer.)

$\endgroup$
1
  • $\begingroup$ Take and Drop are mentioned in the docs for NetChain. No other functions are mention, as far as I saw. $\endgroup$
    – Michael E2
    Dec 7, 2016 at 3:08

1 Answer 1

5
$\begingroup$

If you inspect the output of UpValues[NetChain] and UpValues[NetGraph] besides the Take and Drop there are only Normal and VertexDelete functions it seems.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.