public GruLayer(int xSize, int hSize, IMatrixInitializer <T> linearWeightInitializer, IMatrixInitializer <T> hiddenWeightInitializer, IMatrixInitializer <T> biasInitializer) { _hSize = hSize; _wxh = new NeuroWeight <T>(linearWeightInitializer.CreateMatrix(hSize, xSize)); _wxr = new NeuroWeight <T>(linearWeightInitializer.CreateMatrix(hSize, xSize)); _wxz = new NeuroWeight <T>(linearWeightInitializer.CreateMatrix(hSize, xSize)); _whh = new NeuroWeight <T>(hiddenWeightInitializer.CreateMatrix(hSize, hSize)); _whr = new NeuroWeight <T>(hiddenWeightInitializer.CreateMatrix(hSize, hSize)); _whz = new NeuroWeight <T>(hiddenWeightInitializer.CreateMatrix(hSize, hSize)); _bxh = new NeuroWeight <T>(biasInitializer.CreateMatrix(hSize, 1)); _bxr = new NeuroWeight <T>(biasInitializer.CreateMatrix(hSize, 1)); _bxz = new NeuroWeight <T>(biasInitializer.CreateMatrix(hSize, 1)); _bhh = new NeuroWeight <T>(biasInitializer.CreateMatrix(hSize, 1)); _bhr = new NeuroWeight <T>(biasInitializer.CreateMatrix(hSize, 1)); _bhz = new NeuroWeight <T>(biasInitializer.CreateMatrix(hSize, 1)); ResetOptimizer(); ErrorFunction = new MeanSquareError <T>(); RegisterWeights(); }
public LinearLayer(int xSize, int ySize, IMatrixInitializer <T> matrixInitializer) { _weights = new NeuroWeight <T>(matrixInitializer.CreateMatrix(ySize, xSize)); _bias = new NeuroWeight <T>(matrixInitializer.CreateMatrix(ySize, 1)); ErrorFunction = new MeanSquareError <T>(); RegisterWeights(_bias, _weights); }
public MultiGruLayer(int xSize, int hSize, int layers, IMatrixInitializer <T> linearWeightInitializer, IMatrixInitializer <T> hiddenWeightInitializer, IMatrixInitializer <T> biasInitializer) { if (layers < 1) { throw new ArgumentOutOfRangeException(nameof(layers), "Layer cound should be at least one!"); } _layers = new List <GruLayer <T> >(); _layers.Add(new GruLayer <T>(xSize, hSize, linearWeightInitializer, hiddenWeightInitializer, biasInitializer)); for (int i = 1; i < layers; i++) { _layers.Add(new GruLayer <T>(hSize, hSize, linearWeightInitializer, hiddenWeightInitializer, biasInitializer)); } }
public AffineLayer(int xSize, int ySize, AffineActivation activation, IMatrixInitializer <T> matrixInitializer) { _activationType = activation; _linearLayer = new LinearLayer <T>(xSize, ySize, matrixInitializer); _activationLayer = GetAffineActivationLayer(activation, ySize); }