I 500 pictures of tables and chairs each (849x849) and want to train a convolutional neural net to classify new pictures accordingly. This is my code so far:
cfiles = Import["D:\\Mathematica11\\bo_sample\\chairs\\*"];
tfiles = Import["D:\\Mathematica11\\bo_sample\\tables\\*"];
$train = 300;
trainingData = Join[
Thread[cfiles[[;; $train]] -> "chairs"],
Thread[tfiles[[;; $train]] -> "tables"]
];
testingData = Join[
Thread[cfiles[[$train + 1 ;;]] -> "chairs"] ,
Thread[tfiles[[$train + 1 ;;]] -> "tables"]
];
lenet = NetChain[{ConvolutionLayer[20, 5],
Ramp,
PoolingLayer[2, 2],
ConvolutionLayer[50, 5],
Ramp,
PoolingLayer[2, 2],
FlattenLayer[],
500,
Ramp,
2,
SoftmaxLayer[]},
"Output" -> NetDecoder[{"Class", Range[0, 1]}],
"Input" -> NetEncoder[{"Image", {849, 849}, "RGB"}]];
trainedNN = NetTrain[lenet, trainingData, ValidationSet -> testingData, MaxTrainingRounds -> 3];
...Failure GPU Memory exhausted
It seems the usage of NetTrain is not correct in both cases but the error-messages are not clear to me. Can someone take a look please?
NetInitialize
your graph first. $\endgroup$RandomSample
doesn't work as you expect there, fix it first. $\endgroup$Association
, outputs should be on the right. $\endgroup$