コード例 #1
0
        public static unsafe void bb()
        {
            Terms.Variable w = new Terms.Variable(new Shape(1, 3));
            w.SetValue(new float[1, 3] {
                { 2, 3, 1 }
            });

            Terms.Variable w2 = new Terms.Variable(new Shape(1, 3));
            w2.SetValue(new float[1, 3] {
                { 1, 1, 1 }
            });

            Terms.Add s = new Terms.Add(w, w2);


            Hyperparameters.LearningRate = 1;
            Console.WriteLine(s.GetResult());
            for (int i = 0; i < 1000; i++)
            {
                s.Minimize();
            }
            s.DeleteResults();
            Console.WriteLine(s.GetResult());
            Console.WriteLine(w.GetResult());

            w.Clean();
            w2.Clean();
            s.DeleteResults();
            //Variables should be cleaned manually and disposed manually! All other terms should call dispose method.
        }
コード例 #2
0
 public unsafe DenseModule(int prevsize, int size, string act = "")
 {
     this.activation = act;
     this.size       = size;
     this.prevsize   = prevsize;
     w = new Terms.Variable(new Shape(prevsize, size));
     b = new Terms.Variable(new Shape(1, size));
     Randomiz.Randomize((float *)w.Weights.Array, w.Shape.TotalSize);
     Randomiz.Randomize((float *)b.Weights.Array, b.Shape.TotalSize);
 }