Beispiel #1
0
        public static NDArray <T> Delete <T>(this NDArray <T> np, IEnumerable <T> delete)
        {
            var np1 = np.Array(np.Data.Where(x => !delete.Contains(x)));

            np1.Shape[0] = np.Data.Length;

            return(np1);
        }
        public void Array1Dim()
        {
            var np   = new NDArray <int>();
            var list = new List <int> {
                1, 2, 3
            };

            np = np.Array(list);

            Assert.IsTrue(np.ToString().Equals("array([1, 2, 3])"));
        }
        public NDArray <int> Predict(NDArray <NDArray <double> > X)
        {
            var y_predict = new NDArray <int>().Zeros(X.Length);
            var np        = new NDArray <double>();

            for (int i = 0; i < X.Length; i++)
            {
                var x = X[i];
                ForwardPropagation(x);
                var output = Layers[Layers.Count - 1].Neurons.Select(neuron => neuron.Output).ToList();
                y_predict[i] = np.Array(output).ArgMax();
            }

            return(y_predict);
        }
        public void Array2Dim()
        {
            var np   = new NDArray <List <int> >();
            var list = new List <List <int> >
            {
                new List <int> {
                    1, 2
                },
                new List <int> {
                    3, 4
                }
            };

            np = np.Array(list);

            Assert.IsTrue(np.ToString().Equals("array([[1, 2], [3, 4]])"));
        }
 public static NDArray <TData> Delete <TData>(this NDArray <TData> np, IEnumerable <TData> delete)
 {
     return(np.Array(np.Data.Where(x => !delete.Contains(x))));
 }