Skip to main content
edited title
Link
user64494
  • 1
  • 4
  • 29
  • 60

On Formatting Input data when trainingData When Training Neural Network in Mathematica

edited title
Source Link
Xminer
  • 1.2k
  • 8
  • 15

String Join Error while On Formatting Input data when training Neural-Network Network in Mathematica

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

String Join Error while training Neural-Network

I'm trying to train the following structure of neural networknet
with customized loss functionlossnet

each code and structure isbelow.

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

On Formatting Input data when training Neural Network in Mathematica

I'm trying to train the following structure of neural networknet
with customized loss functionlossnet

each code and structure is 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
Source Link
Xminer
  • 1.2k
  • 8
  • 15

String Join Error while training Neural-Network

I'm trying to train the following structure of neural networknet
with customized loss functionlossnet

each code and structure isbelow.

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