Example #1
0
        //傾きの初期化
        public void ClearGrad()
        {
            this.Grad = new RealArray(this.Data.Length);

            //カウンタをリセット
            this.TrainCount = 0;
        }
Example #2
0
        public void Dispose()
        {
            Data?.Dispose();
            Data = null;

            Grad?.Dispose();
            Grad = null;
        }
Example #3
0
 public NdArray(params int[] shape)
 {
     this.Data       = new RealArray(ShapeToArrayLength(shape));
     this.Shape      = shape.ToArray();
     this.Length     = Data.Length;
     this.BatchCount = 1;
     this.Grad       = new RealArray(this.Length);
     this.TrainCount = 0;
 }
Example #4
0
 public NdArray(Real[] data, int[] shape, int batchCount = 1, Function parentFunc = null)
 {
     this.Shape      = shape.ToArray();
     this.Length     = data.Length / batchCount;
     this.BatchCount = batchCount;
     this.Data       = new RealArray(data.ToArray());
     this.Grad       = new RealArray(this.Length * batchCount);
     this.TrainCount = 0;
     this.ParentFunc = parentFunc;
 }
Example #5
0
 public NdArray(RealArray data, RealArray grad, int[] shape, int batchCount = 1, Function parentFunc = null)
 {
     this.Shape      = shape.ToArray();
     this.Length     = data.Length / batchCount;
     this.BatchCount = batchCount;
     this.Data       = data;
     this.Grad       = grad;
     this.TrainCount = 0;
     this.ParentFunc = parentFunc;
 }
Example #6
0
 public NdArray(int[] shape, int batchCount, Function parentFunc = null)
 {
     this.Shape      = shape.ToArray();
     this.Length     = ShapeToArrayLength(this.Shape);
     this.BatchCount = batchCount;
     this.Data       = new RealArray(this.Length * batchCount);
     this.Grad       = new RealArray(this.Length * batchCount);
     this.TrainCount = 0;
     this.ParentFunc = parentFunc;
 }
Example #7
0
        public NdArray(Array data, Function parentFunc = null)
        {
            Real[] resultData = Real.GetArray(data);

            int[] resultShape = new int[data.Rank];

            for (int i = 0; i < data.Rank; i++)
            {
                resultShape[i] = data.GetLength(i);
            }

            this.Data       = new RealArray(resultData);
            this.Shape      = resultShape;
            this.Length     = Data.Length;
            this.Grad       = new RealArray(this.Length);
            this.BatchCount = 1;
            this.TrainCount = 0;
            this.ParentFunc = parentFunc;
        }
Example #8
0
 public DeviceSwitchHandler(RealArray obj, ComputeDeviceTypes type)
 {
     this.obj  = obj;
     this.type = type;
 }
Example #9
0
 public string ToString(RealArray array)
 {
     return(ToString(array.GetArray()));
 }
Example #10
0
 public static NdArray Convert(RealArray data, int[] shape, int batchCount, Function parentFunc = null)
 {
     return(new NdArray(data, shape, batchCount, parentFunc));
 }