public DQN(MathOperationManager mathManager, DQNNeuralNetworkConfiguration configuration) { if (configuration.LossFunction != LossFunctionType.BellmanError) { throw new ArgumentException("DQN only supports Bellman error. Pls check the configuration passed in."); } base.CreateNeuralNetwork(mathManager, configuration); this.DQNConfiguration = configuration; this.gradientStepCount = 0; var nnStore = this.CreateNeuralNetworkStore(); this.QHat = new NeuralNetwork(this.mathManager, nnStore); }
private static void DQN(IEnumerable <BatchInputWrapper> trainData, IEnumerable <BatchInputWrapper> cvData) { using (MathOperationManager mathManager = new MathOperationManager(MathType.GPU)) { var hiddenLayers = new List <int>(); hiddenLayers.Add(10); hiddenLayers.Add(5); DQNNeuralNetworkConfiguration config = new DQNNeuralNetworkConfiguration(5, hiddenLayers, 12); config.LossFunction = LossFunctionType.BellmanError; config.Epochs = 20; config.StepSize = (float)0.1; using (DQN nn = new DQN(mathManager, config)) { nn.MiniBatchStochasticGradientDescent(trainData, cvData); } } }
private static void DQN(IEnumerable<BatchInputWrapper> trainData, IEnumerable<BatchInputWrapper> cvData) { using (MathOperationManager mathManager = new MathOperationManager(MathType.GPU)) { var hiddenLayers = new List<int>(); hiddenLayers.Add(10); hiddenLayers.Add(5); DQNNeuralNetworkConfiguration config = new DQNNeuralNetworkConfiguration(5, hiddenLayers, 12); config.LossFunction = LossFunctionType.BellmanError; config.Epochs = 20; config.StepSize = (float)0.1; using (DQN nn = new DQN(mathManager, config)) { nn.MiniBatchStochasticGradientDescent(trainData, cvData); } } }