@imaduddin/fastbrain 1.0.6 → 1.0.8
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 +1 -1
- package/src/Softmax/index.js +2 -2
- package/src/model/index.js +1 -1
package/package.json
CHANGED
package/src/Softmax/index.js
CHANGED
|
@@ -124,7 +124,7 @@ export class Softmax {
|
|
|
124
124
|
if(!encoder2) await this.gpu.submitQueue(encoder)
|
|
125
125
|
return this.dLogits
|
|
126
126
|
}
|
|
127
|
-
async crossEntropy(probs, target
|
|
127
|
+
async crossEntropy(probs, target) {
|
|
128
128
|
const encoder = encoderMain ? encoderMain : this.device.createCommandEncoder();
|
|
129
129
|
const tokenCount = probs.size / (this.vocabSize * Float32Array.BYTES_PER_ELEMENT);
|
|
130
130
|
if (!Number.isInteger(tokenCount) || tokenCount <= 0) {
|
|
@@ -182,7 +182,7 @@ export class Softmax {
|
|
|
182
182
|
|
|
183
183
|
return {
|
|
184
184
|
loss: async () =>
|
|
185
|
-
(await this.gpu.readBuffer(
|
|
185
|
+
(await this.gpu.readBuffer(this.loss.size, this.loss)),
|
|
186
186
|
|
|
187
187
|
acc: async () =>
|
|
188
188
|
(await this.gpu.readBuffer(4, this.acc))[0],
|
package/src/model/index.js
CHANGED
|
@@ -63,7 +63,7 @@ export class model {
|
|
|
63
63
|
}
|
|
64
64
|
async backward(x, target, lr) {
|
|
65
65
|
const encoder = await this.op.CreateEncoder()
|
|
66
|
-
const { acc, loss } = await this.softmax.crossEntropy(
|
|
66
|
+
const { acc, loss } = await this.softmax.crossEntropy(x, target)
|
|
67
67
|
let dLogits = await this.softmax.backward(x, target, encoder)
|
|
68
68
|
let dInput = await this.linear.backward(dLogits, lr, encoder)
|
|
69
69
|
for (let i = this.blocks.length - 1; i >= 0; i--) {
|