0
$\begingroup$

I have lists of input and output. I want to perform the prediction operation but my outputs are different for each input and this causes an error. Can someone help me to write the model in such a way that the error is fixed?

input = Partition[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 1];

output = {{{16, 87}, {17, 86}, {17, 87}}, {{26, 84}, {26, 85}}, {{27, 
     83}, {27, 84}, {28, 83}, {28, 84}}, {{31, 82}, {31, 83}}, {{32, 
     82}, {32, 83}, {33, 82}, {33, 83}, {34, 82}, {34, 83}}, {{43, 
     84}, {43, 85}, {44, 84}}, {{55, 86}, {56, 84}, {56, 85}, {57, 
     84}, {57, 85}, {58, 83}, {58, 84}, {59, 83}}, {{64, 81}, {65, 
     79}, {65, 80}}, {{85, 74}, {86, 73}, {86, 74}, {87, 72}, {87, 
     73}, {88, 72}}, {{78, 76}, {79, 74}, {79, 75}}};

{train, test} = TakeDrop[Thread[input -> output], Round[Length[input]*0.8]]

model = NetChain[{UnitVectorLayer[], ConvolutionLayer[2, 2], 
   SoftmaxLayer[]}, "Input" -> 1]

Net = NetTrain[model, train, LearningRate -> 0.002, 
  TargetDevice -> "CPU", WorkingPrecision -> "Real32", 
  BatchSize -> 210]
$\endgroup$
3
  • $\begingroup$ Why are you doing Partition[... , 1] ? It seems unnecessary. Why not just Flatten/@output and then use PadRight to fill the rest with zeros so you have vectors all the same dimensions (maximum length of 8)? Also why are you applying the UnitVectorLayer[] to a single integer input? $\endgroup$
    – flinty
    Commented Mar 14 at 13:54
  • $\begingroup$ Cannot use the PadRight command, because each of them is the position of a point $\endgroup$
    – Erfan
    Commented Mar 14 at 21:25
  • $\begingroup$ In any case, it's not possible to produce variable length output from a neural net like this. $\endgroup$
    – flinty
    Commented Mar 15 at 11:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.