@mineproness/tensorloop 1.4.5 → 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
|
@@ -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
|
-
|
|
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,
|