rethinking design of tensor.

This commit is contained in:
Jordan Hewitt 2024-12-13 09:45:59 -08:00
parent 1162ca9cf9
commit 859f540f4a
2 changed files with 18 additions and 0 deletions

View File

@ -5,6 +5,10 @@ import 'package:collection/collection.dart';
class Tensor extends DelegatingList<DelegatingList<double>> {
Tensor(super.base);
factory Tensor.fromList(List<List<double>> lst) {
return Tensor(DelegatingList(lst.map((e) => DelegatingList(e)).toList()));
}
Tensor each(Function(double, int, int) f) {
Tensor other = Tensor([]);
for (int j = 0; j < length; ++j) {

View File

@ -17,6 +17,20 @@ void main() {
]));
expect(Tensor.stack(x)[0], equals(x));
expect(
Tensor.stack(x),
equals(Tensor.fromList([
[
[
[0.3367, 0.1288, 0.2345],
[0.3367, 0.1288, 0.2345],
],
[
[0.2303, -1.1229, -0.1863],
[0.2303, -1.1229, -0.1863]
]
]
])));
});
});
}