Construct a net that explicitly computes a loss :

net=NetGraph[{LinearLayer[2],SoftmaxLayer[],MeanSquaredLossLayer[]},{1->2->3},"Input"->"Scalar"]

Initialize the net and evaluate it on an input :

net=NetInitialize[net];

net[<|"Input"->1,"Target"->{2,3}|>]