Message Boards Message Boards

Defining NetChain with probabilities and one-hot vector training data

Posted 12 days ago

If you have training data that associates decimal numbers (probabilities) with one-hot vectors (length 10 in this case). How do you describe the input and output in the NetChain function? This is an extract of the code with the stated error message:

A = {0.978, 0.904, 0.766, 0.652, 0.51, 0.34, 0.194, 0.098, 0.035, 0.};
B = {{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 0, 
    0}, {0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 0, 0, 
    0}, {0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1, 0, 0, 0, 
    0}, {0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1, 0, 
    0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 
    1}};
trainingData = Rule @@@ Transpose[{A, B}]
{0.978 -> {1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 
 0.904 -> {0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, 
 0.766 -> {0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, 
 0.652 -> {0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, 
 0.51 -> {0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 
 0.34 -> {0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, 
 0.194 -> {0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, 
 0.098 -> {0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, 
 0.035 -> {0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, 
 0. -> {0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}
net = NetChain[{LinearLayer[4], ElementwiseLayer["ReLU"], 
   LinearLayer[10], SoftmaxLayer[]}]
trainedNet = NetTrain[net, trainingData, MaxTrainingRounds -> 5]

Error Message: NetTrain::skipbatch: Batch #1 will be skipped, because one or or more inputs provided to port "Output" was invalid: input is not an integer between 1 and 10. This batch will be ignored in subsequent training rounds. More information can be obtained via the "SkippedTrainingData" property.

Thanks for any assistance with this.

POSTED BY: Byron Alexander
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract