@mineproness/tensorloop 2.1.53 → 2.1.55
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/Model/index.d.ts +6 -3
- package/src/Model/index.js +6 -11
package/package.json
CHANGED
package/src/Model/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export default class Model{
|
|
1
|
+
export default class Model {
|
|
2
2
|
constructor(embeddingSize: number, contextSize: number, configs: {
|
|
3
3
|
dirname: string,
|
|
4
4
|
activation: "gelu" | "relu",
|
|
5
5
|
})
|
|
6
|
-
train(
|
|
7
|
-
|
|
6
|
+
train(pair: {
|
|
7
|
+
inputIDX: number[],
|
|
8
|
+
targetIDX: number[]
|
|
9
|
+
}[], batchSize: number, batchExecution: number, epochs: number, learningRate: number): void
|
|
10
|
+
}
|
package/src/Model/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Embedding, PositionEmbedding, Linear, Tokenizer, TransformerBlock, Softmax } from '../../index.js'
|
|
2
2
|
import path, { join } from 'path'
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
export default class Model {
|
|
5
5
|
embedding;
|
|
6
6
|
linear;
|
|
@@ -38,18 +38,13 @@ export default class Model {
|
|
|
38
38
|
activation: configs.activation
|
|
39
39
|
})
|
|
40
40
|
}
|
|
41
|
-
train(
|
|
41
|
+
train(pair = {
|
|
42
|
+
inputIDX: [],
|
|
43
|
+
targetIDX: []
|
|
44
|
+
}, epochs = 500, learningRate = 0.01) {
|
|
42
45
|
process.stdout.write("\x1Bc")
|
|
43
46
|
console.log("Preparing Training Pairs....")
|
|
44
|
-
const
|
|
45
|
-
const trainingPair = []
|
|
46
|
-
for (let a = 0; a + this.contextSize < tokens.length; a++) {
|
|
47
|
-
trainingPair.push({
|
|
48
|
-
inputIDX: tokens.slice(a, a + this.contextSize),
|
|
49
|
-
targetIDX: tokens.slice(a + 1, a + this.contextSize + 1)
|
|
50
|
-
})
|
|
51
|
-
if (trainingPair.length == 4000) break;
|
|
52
|
-
}
|
|
47
|
+
const trainingPair = pair
|
|
53
48
|
let firstRun = true;
|
|
54
49
|
console.log(`TotalPairs: ${trainingPair.length}`)
|
|
55
50
|
if (trainingPair.length == 0 || !trainingPair) throw new Error(`The Batch Execution ${batchExecution} is doesn't exist.`);
|