gyrdym / ml_linalg Goto Github PK
View Code? Open in Web Editor NEWSIMD-based linear algebra and statistics for data science with dart
License: BSD 2-Clause "Simplified" License
SIMD-based linear algebra and statistics for data science with dart
License: BSD 2-Clause "Simplified" License
Link to file to reproduce the issue.
The fastSplitMatrix() method is supposed to split a Matrix and output a list of 4 new matrices, each representing a quadrant of the original Matrix. The first matrix in the list is the upper left quadrant, second is the upper right quadrant, third is the lower left quadrant, fourth is the lower right quadrant.
The provided file tries to split a matrix consisting of 1s in the top row, 2s in the second row, 3s in the third row, and 4s in the fourth row. It then prints out the upper-left quadrant (split[0]); this correctly yields the matrix [1, 1; 2, 2].
Examining the cache of split[0] at this point using the Dart debugger shows that rowsCache contains the rows [3, 3] and [4, 4]: these are wrong. The matrix split[0] also has attribute areAllRowsCached set to true, so my guess is the library thinks that the cache is valid.
This behavior manifests when trying to add split[0] to itself: you get a result of [6, 6; 8, 8], presumably from operating on the incorrect cached values.
EDIT: System Details
This is with ml_linalg version 12.17.3.
Line 372 in 6a5c07e
Says min() returns max element. I would hope it returns min element.
I added the required version to my dependencies but I get an error when I run "flutter pub get" in my terminal. The error says:
The current Dart SDK version is 2.3.0-dev.0.5.flutter-a1668566e5.
Because (title_of_my_app) depends on ml_linalg >=10.0.0 which requires SDK version >=2.3.0 <3.0.0, version solving failed.
I already have updated Flutter to the latest version according to Android Studio, so is there something I'm missing here? Thanks
EDIT: If I install a version of this library before 10.0.0, then it works. I just tried installing 9.0.0 and that worked, but if someone could help me figure out why I can't install the latest version that'd be great
Thanks for your detailed readme to explain SIMD in details. It's very attractive to perform SIMD to calculate Vector and Matrix to speed up the performance.
There are many projects are using Google vector classes which provided many tools to perform computation. I know they are using Float64List as underlying storage and would like to know what is the difference between this and their project.
Thanks.
Fix import statements in examples (linalg/linalg_ml -> linalg_nl/linalg), also fix instantiation of a Float32x4Matrix - direct instantiation is prohibited
For information - http://mathworld.wolfram.com/MatrixNorm.html
I could not find the syntax sugar api:
To take m-to-n vectors from Matrix
To remove m-to-n vectors from Matrix
// factorize.dart
import 'dart:math';
import 'package:ml_linalg/linalg.dart';
class Factorization {
Matrix weights;
Matrix features;
Factorization(this.weights, this.features);
}
var weights = Matrix.fromList([
[0.745161771774292, 0.49491751194000244, 0.31594449281692505],
[0.4236903786659241, 0.7222552299499512, 0.03950809687376022]
]);
var features = Matrix.fromList([
[
0.034754883497953415, 0.15588359534740448, 0.6534027457237244, 0.3005395531654358, 0.610332727432251,
0.3886837959289551, 0.8214156031608582, 0.5842974185943604, 0.8119133114814758, 0.0993831604719162,
0.5189520120620728, 0.28814324736595154, 0.07271663844585419, 0.9153922200202942, 0.5082831978797913,
0.9108881950378418, 0.7938997745513916, 0.6407602429389954
],
[
0.7462620735168457, 0.3884164094924927, 0.1176198273897171, 0.7724294662475586, 0.10357396304607391,
0.7664274573326111, 0.5673727989196777, 0.3002673387527466, 0.4880940318107605, 0.5815929770469666, 0.8687184453010559,
0.32184433937072754, 0.15984183549880981, 0.9650658965110779, 0.30762118101119995, 0.4106738269329071, 0.054108526557683945,
0.040961407124996185
],
[
0.6315397620201111, 0.7050033807754517, 0.4593125283718109, 0.816363513469696, 0.6307060718536377, 0.8713419437408447,
0.39600563049316406, 0.9930526614189148, 0.521530270576477, 0.8103489279747009, 0.713289737701416, 0.13782964646816254, 0.8388209939002991,
0.9939820766448975, 0.01218094676733017, 0.744495153427124, 0.041512444615364075, 0.6160798072814941
]
]);
var m = Matrix.fromList([
[4.0, 4.0, 5.0, 5.0, 5.0, 2.0, 2.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[4.0, 5.0, 4.0, 4.0, 5.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 1.0, 1.0, 2.0, 2.0, 1.0]
]);
Factorization factorize(Matrix m, {int numOfFeatures = 3, int numOfIterations = 50}) {
for (var i = 0; i < numOfIterations; i++) {
final wf = weights * features;
if (_cost(m, wf) == 0) break;
final fn = weights.transpose() * m;
final fd = weights.transpose() * weights * features;
features = Matrix.fromRows(
List<Vector>.generate(
features.rowsNum, (row) => features.getRow(row) * fn.getRow(row) / fd.getRow(row)
)
);
//trouble with multiply vectors here -->
final wn = m * features.transpose(); // Matrix (NaN, NaN, NaN)
final wd = weights * features * features.transpose(); // Matrix (NaN, NaN, NaN)
// <--
weights = Matrix.fromRows(
List<Vector>.generate(
weights.rowsNum, (row) => weights.getRow(row) * wn.getRow(row) / wd.getRow(row)
)
);
}
return Factorization(weights, features);
}
double _cost(Matrix a, Matrix b) {
var cost = 0.0;
for (var i = 0; i < a.rowsNum; i++) {
for (var j = 0; j < a.columnsNum; j++) {
cost += pow(a.getRow(i).elementAt(j) - b.getRow(i).elementAt(j), 2);
}
}
return cost;
}
I hope there is a way to create a diagonal matrix by just providing a list of diagonal value.
The method toJson returns naked keys and values (without " around them)
Hi, thanks for this great project and do you have some plan to null-safety?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.