2
$\begingroup$

I'm trying to train a network to take 3 integers and give an output = Max/Min. For example {10, 20, 30} -> 3. But I cannot get the setup correctly. I must be missing something.

x = Table[{RandomInteger[{1, 100}], RandomInteger[{1, 100}], 
    RandomInteger[{1, 100}]}, 1000];
y = (Max[#]/Min[#] // N) & /@ x;
t = x -> y // Thread;
net = NetChain[{LongShortTermMemoryLayer[10], 
   LongShortTermMemoryLayer[10], LinearLayer[1]}, "Input" -> {3, 1}, 
  "Output" -> 1]
p = NetTrain[net, t, ValidationSet -> Scaled[0.1]]

I get the following error:
NetTrain: Data provided to port "Input" should be a non-empty list of 3x1 matrices of real numbers, but was a 1000x3 matrix of real numbers.

$\endgroup$

1 Answer 1

1
$\begingroup$
x = Partition[#, 1] & /@Table[{RandomInteger[{1, 100}], RandomInteger[{1, 100}],RandomInteger[{1, 100}]}, 1000]; 
y = Partition[((Max[#]/Min[#] // N) & /@ x), 1];
t = x -> y // Thread;

net = NetChain[{LongShortTermMemoryLayer[10], LongShortTermMemoryLayer[10], LinearLayer[1]}, "Input" -> {3, 1}, "Output" -> 1]

p = NetTrain[net, t, ValidationSet -> Scaled[0.1]];
NetMeasurements[p, t, "MeanSquare"]

ListPlot[Transpose[{Flatten[p /@ x], Flatten[y]}]]
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.