I am working on something in which I need to train a neural network many times with slightly different training data. I noticed that after many training runs the input rate had dropped significantly.
Below is a simple illustrative example showing the phenomenon.
inputSW = RandomReal[{-1, 1}, {10000, 5}];
target = RandomInteger[{1, 4}, 10000];
trainingData = MapThread[Normalize[#1] -> #2 &, {inputSW, target}];
rates = {};
Do[temp =
NetTrain[NetChain[{16, Ramp, 12, Ramp, 4, SoftmaxLayer[]},
"Output" -> NetDecoder[{"Class", Range[4]}]], trainingData,
"ResultsObject", MaxTrainingRounds -> 4000, BatchSize -> 10000,
TargetDevice -> {"GPU", 2}, TrainingProgressReporting -> "Panel"];
rate = temp["MeanInputsPerSecond"]; PrintTemporary[rate];
rates = Append[rates, rate], 600]
ListPlot@rates
GPU #2 is a GTX 1050 Ti and the list plot looks like this:
Performing more training rounds with:
rates = {};
Do[temp =
NetTrain[NetChain[{16, Ramp, 12, Ramp, 4, SoftmaxLayer[]},
"Output" -> NetDecoder[{"Class", Range[4]}]], trainingData,
"ResultsObject", MaxTrainingRounds -> 4000, BatchSize -> 10000,
TargetDevice -> {"GPU", 2}, TrainingProgressReporting -> "Panel"];
rate = temp["MeanInputsPerSecond"]; PrintTemporary[rate];
rates = Append[rates, rate], 600]
continues the trend:
Restarting the kernel and running more iterations with:
inputSW = RandomReal[{-1, 1}, {10000, 5}];
target = RandomInteger[{1, 4}, 10000];
trainingData = MapThread[Normalize[#1] -> #2 &, {inputSW, target}];
rates = {};
Do[temp =
NetTrain[NetChain[{16, Ramp, 12, Ramp, 4, SoftmaxLayer[]},
"Output" -> NetDecoder[{"Class", Range[4]}]], trainingData,
"ResultsObject", MaxTrainingRounds -> 4000, BatchSize -> 10000,
TargetDevice -> {"GPU", 2}, TrainingProgressReporting -> "Panel"];
rate = temp["MeanInputsPerSecond"]; PrintTemporary[rate];
rates = Append[rates, rate], 600]
ListPlot@rates
resets the input rate:
Without restarting the kernel I train more networks on GPU #1 (Quadro M4000) with
rates = {};
Do[temp =
NetTrain[NetChain[{16, Ramp, 12, Ramp, 4, SoftmaxLayer[]},
"Output" -> NetDecoder[{"Class", Range[4]}]], trainingData,
"ResultsObject", MaxTrainingRounds -> 4000, BatchSize -> 10000,
TargetDevice -> {"GPU", 2}, TrainingProgressReporting -> "Panel"];
rate = temp["MeanInputsPerSecond"]; PrintTemporary[rate];
rates = Append[rates, rate], 600]
and get
Restarting the kernel and training again on GPU #1 gives
This shows that switching the GPU used to train the network "resets" the input rate. Continuing to train on this GPU without restarting the kernel shows the input rate continue to drop
Can others reproduce this? Does anyone have any ideas what might be happening (and how to solve it)?
I am using Mathematica 11.3 on Windows 10.
Update:
Same trend training on a CPU: