Skip to content

Commit 450110b

Browse files
fix: Performance 25% or so faster in chrome/v8 for mse
1 parent 3e8c6ca commit 450110b

6 files changed

Lines changed: 12 additions & 12 deletions

File tree

browser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* license: MIT (http://opensource.org/licenses/MIT)
77
* author: Heather Arthur <fayearthur@gmail.com>
88
* homepage: https://github.com/brainjs/brain.js#readme
9-
* version: 1.4.7
9+
* version: 1.4.8
1010
*
1111
* acorn:
1212
* license: MIT (http://opensource.org/licenses/MIT)
@@ -5347,7 +5347,7 @@ function mse(errors) {
53475347
// mean squared error
53485348
var sum = 0;
53495349
for (var i = 0; i < errors.length; i++) {
5350-
sum += Math.pow(errors[i], 2);
5350+
sum += errors[i] * errors[i];
53515351
}
53525352
return sum / errors.length;
53535353
}

browser.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/utilities/mse.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/utilities/mse.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "brain.js",
33
"description": "Neural network library",
4-
"version": "1.4.7",
4+
"version": "1.4.8",
55
"author": "Heather Arthur <fayearthur@gmail.com>",
66
"repository": {
77
"type": "git",

src/utilities/mse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export default function mse(errors) {
22
// mean squared error
33
let sum = 0;
44
for (let i = 0; i < errors.length; i++) {
5-
sum += Math.pow(errors[i], 2);
5+
sum += errors[i] * errors[i];
66
}
77
return sum / errors.length;
88
}

0 commit comments

Comments
 (0)