예제 #1
0
        public CopyMachine(int weightsCount, NeuralTuringMachine machine)
        {
            _weights   = new double[weightsCount];
            _gradients = new double[weightsCount];

            var extractor = new WeightsExtractor(_weights, _gradients);

            machine.UpdateWeights(extractor);
        }
예제 #2
0
        public AverageMachineWeightUpdater(int weightsCount, NeuralTuringMachine[] machines)
        {
            _weights   = new double[weightsCount];
            _gradients = new double[weightsCount];
            int length    = machines.Length;
            var extractor = new WeightsExtractor(_weights, _gradients);

            foreach (NeuralTuringMachine neuralTuringMachine in machines)
            {
                neuralTuringMachine.UpdateWeights(extractor);
                extractor.Reset();
            }
            for (int i = 0; i < weightsCount; i++)
            {
                _weights[i]   /= length;
                _gradients[i] /= length;
            }
        }