示例#1
0
        //------------- constructors -----------//
        public PerceptronNew(
            IAlgebraLinear <MatrixType> algebra,
            int input_dimensions,
            int output_dimensions,
            IFunction <double, double> output_function,
            IFunction <double, double> output_function_derivative)
        {
            d_random                     = new RNGCryptoServiceProvider();
            d_algebra                    = algebra;
            d_output_function            = output_function;
            d_output_function_derivative = output_function_derivative;
            layerNumber                  = nLayers++; //useful for debugging purposes

            d_input_size  = input_dimensions + 1;     //input + bias
            d_output_size = output_dimensions;

            d_weights            = d_algebra.CreateZeros(d_input_size, d_output_size);
            d_batch_weights      = d_algebra.CreateZeros(d_input_size, d_output_size);
            d_eligibility_traces = d_algebra.CreateZeros(d_input_size, d_output_size);
            d_input          = d_algebra.CreateZeros(1, d_input_size);
            input_error      = d_algebra.CreateZeros(1, d_input_size);
            d_activation     = d_algebra.CreateZeros(1, d_output_size);
            activation_error = d_algebra.CreateZeros(1, d_output_size);
            d_output         = d_algebra.CreateZeros(1, d_output_size);
            d_output_error   = d_algebra.CreateZeros(1, d_output_size);

            ClearInputMatrix();
        }
示例#2
0
        //
        // ------------- constructors -----------//



        public MultiLayerPerceptronNew(
            IAlgebraLinear <DataType> algebra,
            int [] setup,
            IFunction <double, double> output_function,
            IFunction <double, double> output_function_derivative,
            double learning_rate,
            double eligibility)
        {
            d_algebra          = algebra;
            d_random           = new RNGCryptoServiceProvider();
            d_learning_rate    = learning_rate;
            d_eligibility      = eligibility;
            Perceptron.nLayers = 0;
            this.d_setup       = setup;
            d_layer_count      = setup.Length - 1;        // nr of learnable layers, no input layer
            d_layers           = new PerceptronNew <DataType> [d_layer_count];

            // hidden + output layers:
            for (int l = 0; l < d_layer_count; ++l)
            {
                int nInput  = setup[l];                // input size = previous layers output size
                int nOutput = setup[l + 1];            // output size = nr of neurons in this layer

                d_layers[l] = new PerceptronNew <DataType>(d_algebra, nInput, nOutput, output_function, output_function_derivative);
            }
        }
示例#3
0
        public DeconvolutionSVD(IAlgebraLinear <MatrixType> algebra, IFunction <double, double> input_function, double[] signal_sample_times)
        {
            // build AIF matrix

            AMatrix <MatrixType> forward_matrix = null;
            SVD <MatrixType>     svd            = algebra.ComputeSVD(forward_matrix);
        }
示例#4
0
        public TransformWhiteningOld(IAlgebraLinear <MatrixType> algebra,
                                     float [,] data)
        {
            AMatrix <MatrixType> data_matrix = algebra.Create(data);

            means = algebra.Create(ToolsMathStatistics.Means1(data));
            AMatrix <MatrixType> covariance_matrix = data_matrix * data_matrix.Transpose();

            matrix_backward = covariance_matrix.Algebra.ComputeRoot(covariance_matrix);
            matrix_forward  = matrix_backward.Invert();
        }
示例#5
0
        public static void TestMultiplyScalar <MatrixType>(IAlgebraLinear <MatrixType> algebra)
        {
            AMatrix <MatrixType> A = algebra.Create(new double[, ] {
                { 1, 2 }, { 3, 4 }
            });
            AMatrix <MatrixType> C = A * 2;

            Assert.AreEqual(2, C.GetElement(0, 0));
            Assert.AreEqual(4, C.GetElement(0, 1));
            Assert.AreEqual(6, C.GetElement(1, 0));
            Assert.AreEqual(8, C.GetElement(1, 1));
        }
示例#6
0
        public static void TestAddOne <MatrixType>(IAlgebraLinear <MatrixType> algebra)
        {
            AMatrix <MatrixType> A = algebra.Create(new double[, ] {
                { 1, 2 }, { 3, 4 }
            });
            AMatrix <MatrixType> B = A + 1;

            Assert.AreEqual(2, B.GetElement(0, 0));
            Assert.AreEqual(3, B.GetElement(0, 1));
            Assert.AreEqual(4, B.GetElement(1, 0));
            Assert.AreEqual(5, B.GetElement(1, 1));
        }
示例#7
0
        public static void TestMatrixMatrixProduct0 <MatrixType>(IAlgebraLinear <MatrixType> algebra)
        {
            AMatrix <MatrixType> A = algebra.Create(new double[, ] {
                { 1, 0 }, { 0, 1 }
            });
            AMatrix <MatrixType> B = algebra.Create(new double[, ] {
                { 1, 2 }, { 3, 4 }
            });
            AMatrix <MatrixType> C = A * B;

            Assert.AreEqual(1, C.GetElement(0, 0));
            Assert.AreEqual(2, C.GetElement(0, 1));
            Assert.AreEqual(3, C.GetElement(1, 0));
            Assert.AreEqual(4, C.GetElement(1, 1));
        }
        //AMatrix<MatrixType> forward_matrix_flipped;

        public DeconvolutionRichardsonLucy(IAlgebraLinear <MatrixType> algebra, ITemplateBasisFunction template, IFunction <double, double> input_function, double[] signal_sample_times)
        {
            this.algebra             = algebra;
            this.basis_function_list = new List <IFunction <double, double> >();
            double[,] forward_array  = new double[signal_sample_times.Length, signal_sample_times.Length];

            for (int column_index = 0; column_index < signal_sample_times.Length; column_index++)
            {
                IFunction <double, double> basis_function = template.Generate(input_function, signal_sample_times, column_index);
                basis_function_list.Add(basis_function);
                for (int row_index = 0; row_index < signal_sample_times.Length; row_index++)
                {
                    forward_array[row_index, column_index] = basis_function.Compute(signal_sample_times[row_index]);
                }
            }
            forward_matrix = algebra.Create(forward_array);
        }
示例#9
0
        public RendererPoints(IAlgebraLinear <MatrixType> algebra, int bitmap_size_x, int bitmap_size_y, AngleRadian pitch, AngleRadian yaw, double[] offset, double scale)
        {
            this.bitmap_size_x = bitmap_size_x;
            this.bitmap_size_y = bitmap_size_y;
            this.scale         = scale;
            this.offset_matrix = algebra.Create(offset);
            //float [] vector_view = new float[3];
            // unit vector in the direction we view, 0,0 is from the top the regular way,  should produce [0 0 0]
            //(0,0 should procux x = [1 0 0], y = [0 1 0])

            //isometric projection
            //http://www.wolframalpha.com/input/?i=%7B%7B1%2C+0+%2C0%7D%2C%7B0%2C+cos%28a%29%2C+sin%28a%29%7D%2C%7B0%2C+-sin%28a%29%2C+cos%28a%29%7D%7D.%7B%7Bcos%28b%29%2C+0%2C+-sin%28b%29%7D%2C%7B0%2C1%2C0%7D%2C%7Bsin%28b%29%2C+0+%2C+cos%28b%29%7D%7D
            double a = (double)pitch;
            double b = (double)yaw;

            double[,]  projection_array = new double[, ] {
                { Math.Cos(b), Math.Sin(a) * Math.Sin(b), Math.Cos(a) * Math.Sin(b) },
                { 0, Math.Cos(a), -Math.Sin(a) },
                { -Math.Sin(b), Math.Sin(a) * Math.Cos(b), Math.Cos(a) * Math.Cos(b) }
            };

            projection_matrix = algebra.Create(projection_array);
        }
示例#10
0
 public RendererPoints(IAlgebraLinear <MatrixType> algebra, int bitmap_size_x, int bitmap_size_y, AngleRadian pitch, AngleRadian yaw, double scale)
     : this(algebra, bitmap_size_x, bitmap_size_y, yaw, pitch, new double[] { 0, 0, 0 }, scale)
 {
 }
示例#11
0
 public SolverLinearGMRES(IAlgebraLinear <MatrixDataType> algebra)
 {
     this.algebra       = algebra;
     this.simple_solver = algebra.GetSimpleSolver();
 }
 public TemplateDimensionReductionPCA(IAlgebraLinear <MatrixType> algebra, int destination_dimension_count)
 {
     this.algebra = algebra;
     this.destination_dimension_count = destination_dimension_count;
 }
 public DimensionReductionPCA(IDataContext data_context, AMatrix <MatrixType> projection)
 {
     this.DataContext = data_context;
     this.algebra     = projection.Algebra;
     this.projection  = projection;
 }
示例#14
0
 protected AMatrix(IAlgebraLinear <DataType> algebra, DataType data)
 {
     this.Algebra = algebra;
     this.Data    = data;
 }
示例#15
0
 public MatrixKozzion(IAlgebraLinear <DataType [, ]> algebra, DataType[,] data, bool transpose = false)
     : base(algebra, data)
 {
     this.transpose = transpose;
 }