RubixML / Tensor

A library and extension that provides objects for scientific computing in PHP.
https://rubixml.com
MIT License
223 stars 27 forks source link

Tensor 3.0.5 ( multiply strange behavior) #46

Open EDPSH opened 2 months ago

EDPSH commented 2 months ago

My concerns starts with tensor 3.0.5, I talked about it again and my example is T-SNE. PHP 8.2.17 (x64)... tensor 3.0.5... When the tensor 3.0.5 is enabled, then the results for the tsne.php and specific at line 332 of page code

$p = Matrix::quick($this->affinities($distances)) ->multiply($this->exaggeration);

produce all zeros for $p

The example is with dataset iris-flower

Tensor Enabled - results Tensor\Matrix Object ( [a:protected] => Array ( [0] => Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 ......

But if i disabled Tensor 3.0.5

then the results are as this ...

Tensor Disabled - results Tensor\Matrix Object ( [a:protected] => Array ( [0] => Array ( [0] => 0 [1] => 0.21491825237444 [2] => 0.22478852033193 [3] => 0.18097129837837 [4] => 0.40076888328063 [5] => 0.19018111784135 [6] => 0.22138822172434 [7] => 0.38127063420594 [8] => 0.11774974442454 ........

the: $this->affinities($distances) has values the: $this->exaggeration has values but when put them together with tensor enabled, the results are all zero.

andrewdalpino commented 2 months ago

Interesting @EDPSH thank you for the fantastic writeup!

It sounds like there's a problem with the multiplyScalar() method or perhaps even the universal method multiply() that calls multiplyScalar() under the hood.

Digging deeper ...