예제 #1
0
        public Tensor CreateVariable(float[] data, long[] shape, string name = "")
        {
            var arr = new CNTK.NDArrayView(BackendUtil.CastShapeInt(shape), data, DeviceManager.Current);
            var v   = new CNTK.Variable(BackendUtil.CastShapeInt(shape), VariableKind.Parameter, CNTK.DataType.Float, arr, false, new AxisVector(), false, name, name);

            return(Out(v));
        }
예제 #2
0
        private Tensor CreateVariable(int[] data, long[] shape, string name = "")
        {
            shape = BackendUtil.Row2ColMajor(shape);

            var arr = new CNTK.NDArrayView(BackendUtil.CastShapeInt(shape), Array.ConvertAll(data, x => (float)x), DeviceManager.Current);
            var v   = new CNTK.Variable(BackendUtil.CastShapeInt(shape), VariableKind.Input, CNTK.DataType.Float, arr, false, new AxisVector(), false, name, name);

            return(Out(v));
        }
예제 #3
0
        public Tensor RandomUniform(long[] shape, float min, float max, int?seed = null)
        {
            var result = Data.RandUniform <float>(BackendUtil.CastShapeInt(shape));

            if (min != 0 || max != 1)
            {
                result = Data.Constant <float>((max - min), result.Dimensions) * result + Data.Constant <float>(min, result.Dimensions);
            }

            return(Out(result));
        }
예제 #4
0
 public Tensor RandomUniform(long[] shape, float min, float max, int?seed = null)
 {
     if (seed.HasValue)
     {
         return(Out(C.UniformRandom(BackendUtil.CastShapeInt(shape), CNTK.DataType.Float, min, max, (uint)seed.Value)));
     }
     else
     {
         return(Out(C.UniformRandom(BackendUtil.CastShapeInt(shape), CNTK.DataType.Float, min, max)));
     }
 }
예제 #5
0
 public Tensor RandomNormal(long[] shape, float mean, float stddev, int?seed = null)
 {
     if (seed.HasValue)
     {
         return(Out(C.NormalRandom(BackendUtil.CastShapeInt(shape), CNTK.DataType.Float, mean, stddev, (uint)seed.Value)));
     }
     else
     {
         return(Out(C.NormalRandom(BackendUtil.CastShapeInt(shape), CNTK.DataType.Float, mean, stddev)));
     }
 }
예제 #6
0
        public Tensor RandomNormal(long[] shape, float mean, float stddev, int?seed = null)
        {
            var result = Data.RandNormal <float>(BackendUtil.CastShapeInt(shape));

            if (mean != 0 || stddev != 1)
            {
                result = Data.Constant <float>(stddev, result.Dimensions) * result + Data.Constant <float>(mean, result.Dimensions);
            }

            return(Out(result));
        }
예제 #7
0
 public Tensor Constant(float value, long[] shape)
 {
     shape = BackendUtil.Row2ColMajor(shape);
     return(Out(Data.Constant <float>(value, BackendUtil.CastShapeInt(shape))));
 }
예제 #8
0
        private NDArray In(float value, params long[] shape)
        {
            NDArrayTensor tensor = new NDArrayTensor(Data.Constant(value, BackendUtil.CastShapeInt(shape)));

            return(tensor.InternalTensor);
        }
예제 #9
0
 public SiaTensor RandomNormal(long[] shape, float mean, float stddev, int? seed = null)
 {
     return Out(tf.random_normal(BackendUtil.CastShapeInt(shape), mean, stddev, seed: seed));
 }
예제 #10
0
 public SiaTensor RandomUniform(long[] shape, float min, float max, int? seed = null)
 {
     return Out(tf.random_uniform(BackendUtil.CastShapeInt(shape), min, max, seed: seed));
 }
예제 #11
0
 public SiaTensor Reshape(SiaTensor x, params long[] shape)
 {
     return Out(tf.reshape(In(x), BackendUtil.CastShapeInt(shape)));
 }
예제 #12
0
 /// <summary>
 /// Reshapes the data frame to specified new shape.
 /// </summary>
 /// <param name="newShape">The new shape.</param>
 public void Reshape(params long[] newShape)
 {
     UnderlayingVariable = UnderlayingVariable.reshape(new Shape(BackendUtil.CastShapeInt(newShape)));
 }
예제 #13
0
 public Tensor Reshape(Tensor x, params long[] shape)
 {
     return(Out(C.Reshape(In(x), BackendUtil.CastShapeInt(shape))));
 }
예제 #14
0
 public Tensor RandomBernoulli(long[] shape, float p)
 {
     return(Out(C.BernoulliRandom(BackendUtil.CastShapeInt(shape), CNTK.DataType.Float, p)));
 }
예제 #15
0
 private Variable In(float value, params long[] shape)
 {
     return(new Parameter(BackendUtil.CastShapeInt(shape), CNTK.DataType.Float, value));
 }
예제 #16
0
 public void Load(float[] data, long[] shape)
 {
     UnderlayingVariable = np.array <float>(data);
     UnderlayingVariable.reshape(BackendUtil.CastShapeInt(shape));
 }
예제 #17
0
        private Variable In(float value, params long[] shape)
        {
            Constant c = _constant(value, BackendUtil.CastShapeInt(shape));

            return(c);
        }
예제 #18
0
 public Tensor Constant(float value, long[] shape)
 {
     return(Out(Data.Constant <float>(value, BackendUtil.CastShapeInt(shape))));
 }