@mineproness/tensorloop 1.3.0 → 1.3.1

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.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "The most powerfull Machine Learning Library for AI.",
5
5
  "keywords": [
6
6
  "ai",
@@ -9,4 +9,5 @@ export class Linear{
9
9
  forward(input : number[]) : Float32Array[]
10
10
  backward(outGradient : number[] , learingRate: number, idx: number) : Float32Array[]
11
11
  Save() : void
12
+ ClearInputCache() : void
12
13
  }
@@ -55,19 +55,22 @@ export class Linear {
55
55
  }
56
56
  return output
57
57
  }
58
- backward(dOut, lr, stepIndex) {
59
- let dIn = new Float32Array(this.input[stepIndex]);
60
- for (let i = 0; i < this.inputDim; i++) {
61
- let gradSum = 0;
62
- for (let j = 0; j < this.outputDim; j++) {
63
- gradSum += dOut[j] * this.weights[i][j];
64
- this.weights[i][j] -= lr * dOut[j] * this.input[stepIndex][i];
58
+ backward(outputGradient, learningRate) {
59
+ const input = this.input[idx];
60
+ const weights = this.Weights
61
+ const inputGradient = new Float32Array(input.length)
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
65
68
  }
66
- dIn[i] = gradSum;
69
+ this.Bias[a] -= learningRate * gran
67
70
  }
68
- for (let j = 0; j < this.outputDim; j++) {
69
- this.bias[j] -= lr * dOut[j];
70
- }
71
- return dIn;
71
+ return inputGradient
72
+ }
73
+ ClearInputCache(){
74
+ this.input = []
72
75
  }
73
76
  }
package/src.zip DELETED
Binary file