Пример #1
0
        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();
        }
Пример #2
0
        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);
        }
Пример #3
0
        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));
            }
        }
Пример #4
0
 public AffineLayer(int xSize, int ySize, AffineActivation activation, IMatrixInitializer <T> matrixInitializer)
 {
     _activationType  = activation;
     _linearLayer     = new LinearLayer <T>(xSize, ySize, matrixInitializer);
     _activationLayer = GetAffineActivationLayer(activation, ySize);
 }