zerosLike

  1. Tensor!(T, Shape, UseGradient.no) zerosLike(Tensor!(T, Shape, useGradient) x)
  2. Tensor!(T, Shape, useGrad) zerosLike(Tensor!(T, Shape, useGradient) x)
    Tensor!(T, Shape, useGrad)
    zerosLike
    (
    UseGradient useGrad
    T
    size_t[] Shape
    UseGradient useGradient
    )
    (
    Tensor!(T, Shape, useGradient) x
    )

Examples

ditto

auto x = tensor!([2, 2])([1.0f, 2.0f, 3.0f, 4.0f]);
auto x1 = zerosLike(x);

assert(x.shape == x1.shape);
assert(x1.value == zeros!(float, [2, 2]).value);
static assert(!canBackward!(typeof(x1)));

ditto

auto x = tensor!([2, 3])([1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f]);
auto x1 = zerosLike(x);

assert(x.shape == x1.shape);
assert(x1.value == zeros!(float, [2, 3]).value);
static assert(!canBackward!(typeof(x1)));

ditto

auto x = tensor!([2, 3])([1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f]);
auto x1 = zerosLike!(UseGradient.yes)(x);

static assert(canBackward!(typeof(x1)));

Meta