2
$\begingroup$

When the third argument to NetTrain is set to Automatic, how can you tell what loss function it actually used and extract it?

Looking at the docs, I don't see it as a property that can be asked for in the fourth argument.

$\endgroup$
5
$\begingroup$

I agree it would be nice if you could query this information interactively from the progress window after starting a training session. But using a property (4th argument of NetTrain) you can explicitly ask for the 'loss network', which is the network in which loss layers have been attached and which is used to actually do the training.

net = LinearLayer[];
data = {1 -> 1.9, 2 -> 4.1, 3 -> 6.0, 4 -> 8.1};
NetTrain[net, data, Automatic, "LossNet", MaxTrainingRounds -> 1]

In this case you'll see it is a NetGraph that uses a MeanSquaredLossLayer. If the net already has loss layers the loss network is typically the same as the training network.

The actaul internal function is NeuralNetworks`AttachLoss[net, spec] if you want access to it directly. You can leave spec off if you just want the automatic choice.

$\endgroup$
  • $\begingroup$ The "LossNet" argument does not appear to work in version 11.3. Is there a new way to get the information? $\endgroup$ – Seth Chandler Aug 10 '18 at 18:13
1
$\begingroup$

In the doc of NetTrain,it says

When a loss layer is chosen automatically for a port, the loss layer to use is based on the layer within the net whose output is connected to the port

enter image description here

$\endgroup$
  • $\begingroup$ But what is it exactly, are there explicit rules for each type of layer? $\endgroup$ – M.R. Sep 2 '17 at 1:44

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.