public CopyMachine(int weightsCount, NeuralTuringMachine machine) { _weights = new double[weightsCount]; _gradients = new double[weightsCount]; var extractor = new WeightsExtractor(_weights, _gradients); machine.UpdateWeights(extractor); }
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; } }