Ejemplo n.º 1
0
            public NDArray ForwardPass(NDArray input)
            {
                //input has size numDims x inputFeats
                //output has size numDims x outputFeats
                //weights has size inputFeats x outputFeats

                //TODO create weights, create biases,

                //number of input feats
                int num_input  = input.shape[1];
                int num_hidden = 16;
                int num_output = 1;

                var sigmoid = new Sigmoid();
                var tanh    = new Tanh();

                var fc1 = new Linear(num_input, num_hidden);
                var x   = fc1.Apply(input);

                x = tanh.Apply(x);

                var fc2 = new Linear(num_hidden, num_hidden);

                x = fc2.Apply(x);
                x = tanh.Apply(x);

                var fc3 = new Linear(num_hidden, num_output);

                x = fc3.Apply(x);
                x = sigmoid.Apply(x);

                return(x);
            }
Ejemplo n.º 2
0
            public NDArray ForwardPass(NDArray input)
            {
                var x       = input;
                var tanh    = new Tanh();
                var sigmoid = new Sigmoid();

                for (int i = 0; i < layers.Count - 1; i++)
                {
                    x = layers[i].Apply(x);
                    x = tanh.Apply(x);
                }

                //final layer needs to be sigmoid so output in range (0, 1)
                x = layers[layers.Count - 1].Apply(x);
                x = sigmoid.Apply(x);

                return(x);
            }