I'm trying to train the following structure of neural networknet
with customized loss functionlossnet
each code and structure isbelowis below.
net = NetChain[{LinearLayer[10], BatchNormalizationLayer[],
ElementwiseLayer[Tanh], LinearLayer[10]}, "Input" -> 10,
"Output" -> 10]
[![enter image description here][1]][1]
lossnet = NetGraph[<|
"rest" -> SequenceRestLayer[],
"reverse" -> SequenceReverseLayer[],
"firstelement" -> SequenceLastLayer[],
"elementwise" -> ElementwiseLayer[Power[# - 1]^2 &],
"most" -> SequenceMostLayer[],
"last" -> ThreadingLayer[(#1 - #2 - 1)^2 &],
"out" -> SummationLayer[],
"summary" -> ThreadingLayer[Plus]
|>,
{
NetPort["Input"] -> "rest",
NetPort["Input"] -> "reverse",
"reverse" -> "firstelement",
"firstelement" -> "elementwise",
NetPort["Input"] -> "most",
"rest" -> "last",
"most" -> "last",
"last" -> "out",
{"out", "elementwise"} -> "summary"}]
[![enter image description here][2]][2]
but when start training,I encountered this error.
NetTrain[net, <|NetPort["Input"] -> {Range[1, 10]}|>,
LossFunction -> lossnet]
NetTrain::missinslot: Training data specification should include values for the port Input, but only contains values for the port NetPort[Input]. You may need to explicitly specify the loss port(s) of the net using LossFunction.
it seems that something related to my input is wrong,but I don't know where it is.
perhaps,this is a rudimentary mistake,though.
what is wrong?
[1]: https://i.sstatic.net/AcWPY.jpg [2]: https://i.sstatic.net/XUTbt.jpg