TensorDistribution<T> class
abstract
A distribution that samples tensor element values from independent distributions.
Example
import 'package:calc/calc.dart';
void main() {
// Construct a distribution for matrices 2 rows and 3 columns.
// Each element is sampled from unit normal distribution.
const distribution = TensorDistribution.filled(
TensorShape([2,3]),
NormalDistribution(mean: 0.0, variance:1.0),
);
// Sample the distribution.
final tensor = distribution.sample();
}
- Inheritance
-
- Object
- Distribution<
Tensor< T> > - TensorDistribution
Constructors
-
TensorDistribution.filled(TensorShape shape, Distribution<
T> distribution) -
Constructing a distribution where all indices have identical scalar
distribution.
factory
-
TensorDistribution.fitScalarsIndependently(Iterable<
Tensor< iterable, Distribution<double> >T> scalarFitter(Iterable<double> iterable)) -
Constructs a distribution by fitting a distribution to each index
independently.
factory
-
TensorDistribution.generate(TensorShape shape, Distribution<
T> generator(TensorShape shape, int index)) -
Generates distribution for each index independently.
factory
Properties
-
distributions
→ List<
Distribution< T> > -
Distribution for each (flat) index of the tensor.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shape → TensorShape
-
Shape of the tensor.
no setter
Methods
-
map<
R> (R f(Tensor< T> value)) → Distribution<R> -
Maps samples of the distribution with the given function.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sample(
{Random? random}) → Tensor< T> -
Generates a random sample.
inherited
-
sampleList(
int length, {Random? random}) → List< Tensor< T> > -
Generates a list of N random samples.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited