Exemplo n.º 1
0
        //------------- public functions -----------//

        /*
         * processing functions
         */
        public float[] process(float[] input)
        {
            //apply function y = f(Wx)
            //store local copy of the input and create space for bias
            ToolsCollection.CopyRBA(input, d_input);
            d_input[d_input_size - 1] = 1.0f;     //put in bias

            //calculate and store activation
            ToolsCollection.SetValue(d_activation, 0.0f);
            for (int o = 0; o < d_output_size; o++)
            {
                for (int i = 0; i < d_input_size; i++)
                {
                    d_activation[o] += d_weights[o, i] * d_input[i];
                }
            }
            //calculate and store output
            for (int o = 0; o < d_output_size; o++)
            {
                d_output[o] = d_output_function.Compute((float)d_activation[o]); //TODO double?
            }

            //and return the output to be processed by later layers
            return(d_output);
        }
Exemplo n.º 2
0
 public static double[] IntegrateStatic(IFunction <double[], double[], double[]> differntial, double[] history, double[] inital_value, double step_size)
 {
     double[] k1   = ToolsMathCollectionDouble.Multply(differntial.Compute(inital_value, history), step_size / 6.0);
     double[] temp = ToolsMathCollectionDouble.Add(inital_value, ToolsMathCollectionDouble.Multply(k1, 0.5));
     double[] k2   = ToolsMathCollectionDouble.Multply(differntial.Compute(temp, history), step_size / 3.0f);
     temp = ToolsMathCollectionDouble.Add(inital_value, ToolsMathCollectionDouble.Multply(k2, 0.5));
     double[] k3 = ToolsMathCollectionDouble.Multply(differntial.Compute(temp, history), step_size / 3.0f);
     temp = ToolsMathCollectionDouble.Add(inital_value, k2);
     double[] k4 = ToolsMathCollectionDouble.Multply(differntial.Compute(temp, history), step_size / 6.0f);
     ToolsCollection.CopyRBA(inital_value, temp);
     for (int index = 0; index < inital_value.Length; index++)
     {
         temp[index] += k1[index] + k2[index] + k3[index] + k4[index];
     }
     return(temp);
 }
Exemplo n.º 3
0
        public override bool ComputeRBA(IMarketModelIndicator market_model, double[] target)
        {
            bool all_valid = true;

            for (int indicator_index = 0; indicator_index < indicators.Count; indicator_index++)
            {
                IIndicator             inidicator = indicators[indicator_index];
                Tuple <double[], bool> tuple      = inidicator.Compute(market_model);
                ToolsCollection.CopyRBA(tuple.Item1, 0, target, indicator_offsets[indicator_index], inidicator.SubIndicatorCount);

                if (!tuple.Item2)
                {
                    all_valid = false;
                }
            }
            return(all_valid);
        }
Exemplo n.º 4
0
        public IImageRaster2D <float> Render(IImageSpace <float, float> source_image)
        {
            IImageRaster2D <float> destination_image = new ImageRaster2D <float>();

            float[] coordinates = new float [render_origen.Length];
            for (int index_y = 0; index_y < this.resolution_y; index_y++)
            {
                for (int index_x = 0; index_x < this.resolution_x; index_x++)
                {
                    ToolsCollection.CopyRBA(this.render_origen, coordinates);
                    for (int index_dimension = 0; index_dimension < this.dimension_count; index_dimension++)
                    {
                        coordinates[index_dimension] += (render_stride_x[index_dimension] * index_x) + (render_stride_y[index_dimension] * index_y);
                    }
                    destination_image.SetElementValue(index_x, index_y, source_image.GetLocationValue(coordinates));
                }
            }
            return(destination_image);
        }
        public LabelType[] Maximize(ObeservationType [] observations, LabelType [] state)
        {
            LabelType [] new_state = new LabelType[state.Length];

            for (int index_iteration = 0; index_iteration < d_iteration_count; index_iteration++)
            {
                // expectation
                IFunction <Tuple <ObeservationType[], LabelType[], int>, LabelType> expectation_function = d_generator.generate(observations, state);


                // maximazation
                for (int index_element = 0; index_element < state.Length; index_element++)
                {
                    new_state[index_element] = expectation_function.Compute(new Tuple <ObeservationType[], LabelType[], int>(observations, state, index_element));
                }
                ToolsCollection.CopyRBA(state, new_state);
            }


            return(state);
        }
Exemplo n.º 6
0
 public void ToolsCollectionCopyRBATest()
 {
     float[,,] source = new float[2, 2, 2];
     source[0, 0, 0]  = 0;
     source[0, 0, 1]  = 1;
     source[0, 1, 0]  = 2;
     source[0, 1, 1]  = 3;
     source[1, 0, 0]  = 4;
     source[1, 0, 1]  = 5;
     source[1, 1, 0]  = 6;
     source[1, 1, 1]  = 7;
     float[,,] target = new float[2, 2, 2];
     ToolsCollection.CopyRBA(source, target);
     Assert.Equals(target[0, 0, 0], source[0, 0, 0]);
     Assert.Equals(target[0, 0, 1], source[0, 0, 1]);
     Assert.Equals(target[0, 1, 0], source[0, 1, 0]);
     Assert.Equals(target[0, 1, 1], source[0, 1, 1]);
     Assert.Equals(target[1, 0, 0], source[1, 0, 0]);
     Assert.Equals(target[1, 0, 1], source[1, 0, 1]);
     Assert.Equals(target[1, 1, 0], source[1, 1, 0]);
     Assert.Equals(target[1, 1, 1], source[1, 1, 1]);
 }
Exemplo n.º 7
0
 public void SetVertex(int vertex_index, double[] vertex_parameters, double vertex_value)
 {
     ToolsCollection.CopyRBA(vertex_parameters, vertexes[vertex_index]);
     SetVertexValue(vertex_index, vertex_value);
 }