public static NDArray Maximum(float a, NDArray b) { var a_t = new NDArray(b.Allocator, b.ElementType, b.Shape); TOps.Fill(a_t, a); return(Maximum(a_t, b)); }
public static NDArray Constant(float value, IAllocator allocator, DType dtype, params long[] sizes) { NDArray tensor = new NDArray(allocator, dtype, sizes); TOps.Fill(tensor, value); return(tensor); }
public static NDArray Maximum(NDArray a, float b) { var b_t = new NDArray(a.Allocator, a.ElementType, a.Shape); TOps.Fill(b_t, b); return(Maximum(a, b_t)); }
public Tensor RandomBernoulli(long[] shape, float p) { var result = new NDArray(DeviceManager.Current, DType.Float32, shape); TOps.RandomBernoulli(result, new SeedSource(), p); return(Out(result)); }
/// <summary> /// Transposes the specified dimension1. /// </summary> /// <param name="dimension1">The dimension1.</param> /// <param name="dimension2">The dimension2.</param> /// <returns>Tensor.</returns> /// <exception cref="ArgumentOutOfRangeException"> /// dimension1 /// or /// dimension2 /// </exception> private NDArray Transpose(int dimension1, int dimension2, bool NewContiguous = false) { if (dimension1 < 0 || dimension1 >= DimensionCount) { throw new ArgumentOutOfRangeException("dimension1"); } if (dimension2 < 0 || dimension2 >= DimensionCount) { throw new ArgumentOutOfRangeException("dimension2"); } if (dimension1 == dimension2) { storage.AddRef(); return(this); } var newSizes = (long[])shape.Clone(); var newStrides = (long[])strides.Clone(); ArraySwap(newSizes, dimension1, dimension2); ArraySwap(newStrides, dimension1, dimension2); if (NewContiguous) { return(TOps.NewContiguous(new NDArray(newSizes, newStrides, storage, storageOffset)).Reshape(newSizes)); } return(new NDArray(newSizes, newStrides, storage, storageOffset)); }
public Tensor StdDev(Tensor x, int dim) { if (dim < 0) { dim = x.Shape.Length + dim; } return(Out(TOps.Std(In(x), dim, false))); }
public Tensor RandomNormal(long[] shape, float mean, float stddev, int?seed = null) { var result = new NDArray(DeviceManager.Current, DType.Float32, shape); var seedSource = new SeedSource(); if (seed.HasValue) { seedSource = new SeedSource(seed.Value); } TOps.RandomNormal(result, seedSource, mean, stddev); return(Out(result)); }
public Tensor RandomUniform(long[] shape, float min, float max, int?seed = null) { var result = new NDArray(DeviceManager.Current, DType.Float32, shape); var seedSource = new SeedSource(); if (seed.HasValue) { seedSource = new SeedSource(seed.Value); } TOps.RandomUniform(result, seedSource, min, max); return(Out(result)); }
public Tensor Prod(Tensor x, int dim) { return(Out(TOps.Prod(In(x), dim))); }
public float Min(Tensor x) { return(TOps.MinF(In(x))); }
public Tensor EqualTo(Tensor a, Tensor b) { return(Out(TOps.EqualTo(In(a), In(b)))); }
public Tensor Atan2(Tensor lhs, Tensor rhs) { return(Out(TOps.Atan2(In(lhs), In(rhs)))); }
public Tensor Clip(Tensor x, float min, float max) { return(Out(TOps.Clip(In(x), min, max))); }
public Tensor Var(Tensor x, int dim) { return(Out(TOps.Var(In(x), dim, false))); }
public float StdDev(Tensor x) { return(TOps.StdF(In(x))); }
public float Var(Tensor x) { return(TOps.VarF(In(x))); }
public Tensor Acos(Tensor x) { return(Out(TOps.Acos(In(x)))); }
public Tensor Mean(Tensor x, params int[] dim) { return(Out(TOps.Mean(In(x), dim))); }
public Tensor Mean(Tensor x, int dim) { return(Out(TOps.Mean(In(x), dim))); }
public float Mean(Tensor x) { return(TOps.MeanF(In(x))); }
public Tensor Diag(Tensor x) { return(Out(TOps.Diag(In(x)))); }
public float Max(Tensor x) { return(TOps.MaxF(In(x))); }
public Tensor Atan(Tensor x) { return(Out(TOps.Atan(In(x)))); }
public float Prod(Tensor x) { return(TOps.ProdF(In(x))); }
public Tensor Ceil(Tensor x) { return(Out(TOps.Ceil(In(x)))); }
public Tensor Maximum(Tensor a, float b) { return(Out(TOps.Maximum(In(a), b))); }
public Tensor Cosh(Tensor x) { return(Out(TOps.Cosh(In(x)))); }
public Tensor Max(Tensor x, int dim) { return(Out(TOps.Max(In(x), dim))); }
public Tensor Maximum(Tensor a, Tensor b) { return(Out(TOps.Maximum(In(a), In(b)))); }
public Tensor Sum(Tensor x, params int[] dim) { return(Out(TOps.Sum(In(x), dim))); }