ones

  1. Tensor!(T, Shape, useGrad) ones()
  2. Tensor!(T, Shape, useGrad) ones(size_t batchSize)
    Tensor!(T, Shape, useGrad)
    ones
    (
    T
    size_t[] Shape
    )
    (
    size_t batchSize
    )
    if (
    Shape[0] == 0
    )

Examples

ditto

auto o = ones!(float, [2, 2]);
assert(!canBackward!(typeof(o)));
assert(o.shape == [2, 2]);
assert(o.value[0, 0] == 1);
assert(o.value[0, 1] == 1);
assert(o.value[1, 0] == 1);
assert(o.value[1, 1] == 1);

ditto

auto o = ones!(float, [0, 2])(2);
assert(!canBackward!(typeof(o)));
assert(o.shape == [2, 2]);
assert(o.value[0, 0] == 1);
assert(o.value[0, 1] == 1);
assert(o.value[1, 0] == 1);
assert(o.value[1, 1] == 1);

ditto

auto o = ones!(float, [2, 3], UseGradient.yes);
static assert(canBackward!(typeof(o)));

Meta