1
$\begingroup$

I have a simple chain in Mathematica

myChain = NetChain[{
  LinearLayer[100],
  myLittleChain[],
  LinearLayer[25],
  SoftmaxLayer[]
}]

with a sub-chain

myLittleChain[] = NetChain[{LinearLayer[50], Ramp}]

I can access the output of say the first linear layer with

NetMeasurements[myTrainedChain, someData, NetPort[{1, "Output"}]];

But how do I access the output from the linear layer inside the sub-chain. I want a way which would generalize to netgraphs so I could potentially have several sub-chains in parallel.

$\endgroup$
2
  • $\begingroup$ Are you looking to create a network that has multiple outputs in practice? If so, you will want to use NetGraph (instead of NetChain) and define multiple output ports. If instead you're merely looking to extract what the values are from your trained network, something like subNet= NetTake[myTrainedChain,2] will extract the part of your network up to the second layer. You can then feed data into subNet and see what the output is. $\endgroup$ May 8 at 13:17
  • $\begingroup$ It’s the second of these, i.e., to monitor what the network is doing, that I am interested in. I see how your suggestion could be useful in some circumstances, but I am interested in what is going on at a particular layer when I feed real data into the top level. I just can’t see an easy way of referencing a layer in a sub-net in a way that NetPort will accept. $\endgroup$
    – user121049
    May 8 at 16:41

Your Answer

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

Browse other questions tagged or ask your own question.