@mineproness/tensorloop 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mineproness/tensorloop",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "The most powerfull Machine Learning Library for AI.",
5
5
  "keywords": [
6
6
  "ai",
@@ -56,13 +56,17 @@ export class Linear {
56
56
  return output
57
57
  }
58
58
  backward(outputGradient, learningRate) {
59
+ const input = this.input;
60
+ const weights = this.Weights
59
61
  const inputGradient = new Float32Array(this.input.length)
60
- for (let a = 0; a < this.Weights.length; a++) {
61
- for (let at = 0; at < this.input.length; at++) {
62
- inputGradient[at] += outputGradient[a] * this.Weights[a][at]
63
- this.Weights[a][at] -= learningRate * this.input[at] * outputGradient[a]
62
+ for (let a = 0; a < weights.length; a++) {
63
+ const gran = outputGradient[a]
64
+ const w = weights[a]
65
+ for (let at = 0; at < input.length; at++) {
66
+ inputGradient[at] += gran * w[at]
67
+ w[at] -= learningRate * input[at] * gran
64
68
  }
65
- this.Bias[a] -= learningRate * outputGradient[a]
69
+ this.Bias[a] -= learningRate * gran
66
70
  }
67
71
  return inputGradient
68
72
  }