rethinking design of tensor.
This commit is contained in:
parent
1162ca9cf9
commit
859f540f4a
@ -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) {
|
||||
|
@ -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]
|
||||
]
|
||||
]
|
||||
])));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user