TensorDistribution<T>.generate constructor

TensorDistribution<T>.generate(
  1. TensorShape shape,
  2. Distribution<T> generator(
    1. TensorShape shape,
    2. int index
    )
)

Generates distribution for each index independently.

Implementation

factory TensorDistribution.generate(
  TensorShape shape,
  Distribution<T> Function(TensorShape shape, int index) generator,
) {
  final distributions =
      List<Distribution<T>>.generate(shape.numberOfElements, (index) {
    return generator(shape, index);
  });
  return _TensorDistribution<T>(shape, distributions);
}