@mineproness/tensorloop 1.4.4 → 1.4.6

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.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "The most powerfull Machine Learning Library for AI.",
5
5
  "keywords": [
6
6
  "ai",
@@ -40,18 +40,19 @@ export class TransformerBlock {
40
40
  return output
41
41
  }
42
42
  backward(dOutput, learningRate) {
43
- const dFFN = this.ffn.backward(
44
- dOutput,
45
- learningRate
46
- )
43
+ const dFFN = this.ffn.backward(dOutput, learningRate)
47
44
  const dResidual1 = []
48
-
49
45
  for (let a = 0; a < dFFN.length; a++) {
50
- dResidual1[a] = this.norm2.backward(
46
+ const dNorm2 = this.norm2.backward(
51
47
  dFFN[a],
52
48
  learningRate,
53
49
  a
54
50
  )
51
+ dResidual1[a] = new Float32Array(dOutput[a].length)
52
+ for (let i = 0; i < dOutput[a].length; i++) {
53
+ dResidual1[a][i] =
54
+ dOutput[a][i] + dNorm2[i]
55
+ }
55
56
  }
56
57
  const dAttention = this.selfAttention.backward(
57
58
  dResidual1,
@@ -78,7 +79,7 @@ export class TransformerBlock {
78
79
  return dInput
79
80
  }
80
81
  clearInputCache() {
81
- this.ffn.clearInputCache()
82
+ this.ffn.ClearInputCache()
82
83
  this.selfAttention.key.ClearInputCache()
83
84
  this.selfAttention.query.ClearInputCache()
84
85
  this.selfAttention.value.ClearInputCache()