public Scalar Item() { var sptr = THSTensor_item(Handle); Torch.AssertNoErrors(); return(new Scalar(sptr)); }
public TorchTensor this[long i1] { get { return(new TorchTensor(THSTensor_get1(handle, i1))); } set { THSTensor_set1(handle, i1, value.Item().Handle); Torch.AssertNoErrors(); } }
public static Loss PoissonNLL(bool logInput = true, bool full = false, float eps = 1e-8f, Reduction reduction = Reduction.Mean) { return((TorchTensor src, TorchTensor target) => { var tptr = THSNN_loss_poisson_nll(src.Handle, target.Handle, logInput, full, eps, (long)reduction); Torch.AssertNoErrors(); return new TorchTensor(tptr); }); }
/// <summary> /// Create a new tensor filled with random values taken from a uniform distribution in [0, 1). /// </summary> static public TorchTensor Random(long[] size, string device = "cpu", bool requiresGrad = false) { TorchTensor.CheckForCUDA(device); unsafe { fixed(long *psizes = size) { var tptr = THSTensor_rand((IntPtr)psizes, size.Length, (sbyte)ATenScalarMapping.Float, device, requiresGrad); Torch.AssertNoErrors(); return(new TorchTensor(tptr)); } } }