Tensor.ones constructor

Tensor.ones(
  1. List<int> shape
)

Creates a tensor filled with ones.

Implementation

factory Tensor.ones(List<int> shape) {
  final size = _productOfShape(shape);
  final data = Float32List(size);
  for (int i = 0; i < size; i++) {
    data[i] = 1.0;
  }
  return Tensor(data, List<int>.from(shape));
}