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)); }
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)); }
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)); }
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))); } }
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))); } }
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)); }
public Tensor Constant(float value, long[] shape) { shape = BackendUtil.Row2ColMajor(shape); return(Out(Data.Constant <float>(value, BackendUtil.CastShapeInt(shape)))); }
private NDArray In(float value, params long[] shape) { NDArrayTensor tensor = new NDArrayTensor(Data.Constant(value, BackendUtil.CastShapeInt(shape))); return(tensor.InternalTensor); }
public SiaTensor RandomNormal(long[] shape, float mean, float stddev, int? seed = null) { return Out(tf.random_normal(BackendUtil.CastShapeInt(shape), mean, stddev, seed: seed)); }
public SiaTensor RandomUniform(long[] shape, float min, float max, int? seed = null) { return Out(tf.random_uniform(BackendUtil.CastShapeInt(shape), min, max, seed: seed)); }
public SiaTensor Reshape(SiaTensor x, params long[] shape) { return Out(tf.reshape(In(x), BackendUtil.CastShapeInt(shape))); }
/// <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))); }
public Tensor Reshape(Tensor x, params long[] shape) { return(Out(C.Reshape(In(x), BackendUtil.CastShapeInt(shape)))); }
public Tensor RandomBernoulli(long[] shape, float p) { return(Out(C.BernoulliRandom(BackendUtil.CastShapeInt(shape), CNTK.DataType.Float, p))); }
private Variable In(float value, params long[] shape) { return(new Parameter(BackendUtil.CastShapeInt(shape), CNTK.DataType.Float, value)); }
public void Load(float[] data, long[] shape) { UnderlayingVariable = np.array <float>(data); UnderlayingVariable.reshape(BackendUtil.CastShapeInt(shape)); }
private Variable In(float value, params long[] shape) { Constant c = _constant(value, BackendUtil.CastShapeInt(shape)); return(c); }
public Tensor Constant(float value, long[] shape) { return(Out(Data.Constant <float>(value, BackendUtil.CastShapeInt(shape)))); }