@genai-fi/nanogpt 0.6.0 → 0.6.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/dist/Generator.js +7 -7
- package/dist/NanoGPTModel.js +70 -121
- package/dist/RealDiv-7xu-pkZN.js +540 -0
- package/dist/Reshape-BYC1oUku.js +127 -0
- package/dist/TeachableLLM.d.ts +2 -0
- package/dist/TeachableLLM.js +34 -27
- package/dist/{TiedEmbedding-BhxWO8QR.js → TiedEmbedding-C1HBot-5.js} +12 -13
- package/dist/{axis_util-D17qZRQm.js → axis_util-CCNL7jea.js} +14 -12
- package/dist/{broadcast_to-BMQLjvt_.js → broadcast_to-CddAF879.js} +2 -2
- package/dist/{concat-DhZfF1GY.js → concat-XOK9ANZu.js} +7 -7
- package/dist/{dataset-oilnemHf.js → dataset-BFFipD1c.js} +5 -5
- package/dist/{dropout-CrMQPCeG.js → dropout-xlKRoJyU.js} +9 -9
- package/dist/{gather-DZCMHZuN.js → gather-DKtUaTtA.js} +1 -1
- package/dist/gpgpu_math-B_ycgZ4W.js +3115 -0
- package/dist/{index-bMBtI-WR.js → index-CamYe_M8.js} +843 -646
- package/dist/{kernel_funcs_utils-CNmjLWnB.js → kernel_funcs_utils-D5MS0JFg.js} +232 -138
- package/dist/layers/BaseLayer.js +2 -2
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +5 -5
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +13 -33
- package/dist/layers/TiedEmbedding.js +6 -7
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/{log_sum_exp-BHdkCb4s.js → log_sum_exp-CV_5-TTu.js} +15 -15
- package/dist/main.js +23 -20
- package/dist/{mat_mul-BsrLfy81.js → mat_mul-CAbRFWUj.js} +4 -4
- package/dist/{max-DechV4Bc.js → max-JBBv7aUf.js} +3 -3
- package/dist/mulmat_packed_gpu-DW4doKL_.js +71 -0
- package/dist/{norm-B9hWHZH1.js → norm-B9dQTFYn.js} +12 -12
- package/dist/{ones-g0K8jVwm.js → ones-CMHNqMr6.js} +2 -2
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +5 -5
- package/dist/ops/cpu/fusedSoftmax.js +2 -2
- package/dist/ops/cpu/gatherSub.js +5 -5
- package/dist/ops/cpu/gelu.js +1 -1
- package/dist/ops/cpu/matMulGelu.js +1 -1
- package/dist/ops/cpu/matMulMul.js +1 -1
- package/dist/ops/cpu/mulDropout.js +1 -1
- package/dist/ops/cpu/normRMS.js +1 -1
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +18 -49
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +1 -1
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +1 -1
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/normRMS.js +1 -1
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +1 -1
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/node/sparseCrossEntropy.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/rope.js +8 -4
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +29 -560
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +3 -3
- package/dist/ops/webgl/matMulGelu.js +48 -115
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +1 -1
- package/dist/ops/webgl/normRMS.js +2 -2
- package/dist/ops/webgl/qkv.js +1 -1
- package/dist/ops/webgl/rope.js +1 -1
- package/dist/ops/webgl/scatterSub.js +1 -1
- package/dist/{ops-Mv7Ta72x.js → ops-DqtYemmV.js} +143 -135
- package/dist/{random_width-BBAWzDym.js → random_width-CLMQG5Jn.js} +6925 -6291
- package/dist/{range-DMaG9A3G.js → range-DqYjKnuG.js} +1 -1
- package/dist/{gpgpu_math-Ctc31slO.js → reciprocal-z49filta.js} +7 -5
- package/dist/register_all_kernels-COt6wLD0.js +21397 -0
- package/dist/{reshape-T4yDEqoF.js → reshape-C45vIIRU.js} +1 -1
- package/dist/scatter_nd_util-qgtnviTE.js +46 -0
- package/dist/selu_util-4QV_GXTB.js +740 -0
- package/dist/{shared-XNAoXhOa.js → shared-ByfrGA97.js} +1462 -1089
- package/dist/{sin-EEhbrRO_.js → sin-9JBrfVaB.js} +1 -1
- package/dist/{softmax-B2_IKPDR.js → softmax-DvMvui-_.js} +1 -1
- package/dist/{split-dcks18H1.js → split-DxrHrPFK.js} +4 -4
- package/dist/{stack-lpJ5kYvE.js → stack-DgaoDmnF.js} +1 -1
- package/dist/{sum-CutF5lj2.js → sum-BpcpxNEh.js} +3 -3
- package/dist/{tensor-C15NA2LA.js → tensor-CDz5x1mP.js} +1 -1
- package/dist/{tensor2d-DZ_e5eKM.js → tensor2d-jO8JY5Jd.js} +1 -1
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +3 -3
- package/dist/training/sparseCrossEntropy.js +4 -4
- package/dist/utilities/dummy.d.ts +6 -0
- package/dist/utilities/dummy.js +31 -10
- package/dist/utilities/generate.js +3 -3
- package/dist/utilities/load.js +1 -1
- package/dist/utilities/profile.d.ts +5 -0
- package/dist/utilities/profile.js +10 -7
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-CdRKKp8x.js → variable-CLVXjN7F.js} +1 -1
- package/dist/{zeros-CAbHfODe.js → zeros-DUkkVccu.js} +8 -8
- package/package.json +3 -9
- package/dist/Reshape-CLOrdpve.js +0 -212
- package/dist/slice_util-Ddk0uxGJ.js +0 -49
- package/dist/tfjs_backend-BDb8r9qx.js +0 -1010
package/dist/TeachableLLM.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { defaultConfig as
|
|
1
|
+
import { defaultConfig as d } from "./config.js";
|
|
2
2
|
import l from "./NanoGPTModel.js";
|
|
3
|
-
import { saveModel as
|
|
4
|
-
import { loadModel as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { E as
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
3
|
+
import { saveModel as f } from "./utilities/save.js";
|
|
4
|
+
import { loadModel as u } from "./utilities/load.js";
|
|
5
|
+
import p from "./Generator.js";
|
|
6
|
+
import _ from "./Trainer.js";
|
|
7
|
+
import { E as c } from "./index-Dwqa6Zy2.js";
|
|
8
|
+
import { dummyPassTrainAsync as m } from "./utilities/dummy.js";
|
|
9
|
+
import g from "./tokeniser/CharTokeniser.js";
|
|
10
|
+
import w from "./tokeniser/bpe.js";
|
|
11
11
|
import "./papaparse.min-C8l2Kvo1.js";
|
|
12
12
|
import "./index-Tf7vU29b.js";
|
|
13
13
|
import "./jszip.min-CjP2V1VV.js";
|
|
14
|
-
import "./index-
|
|
14
|
+
import "./index-CamYe_M8.js";
|
|
15
15
|
import "./ops/cpu/scatterSub.js";
|
|
16
16
|
import "./ops/webgl/scatterSub.js";
|
|
17
17
|
import "./ops/cpu/gatherSub.js";
|
|
@@ -22,7 +22,9 @@ import "./ops/grads/attentionMask.js";
|
|
|
22
22
|
import "./ops/cpu/qkv.js";
|
|
23
23
|
import "./ops/webgl/qkv.js";
|
|
24
24
|
import "./ops/grads/qkv.js";
|
|
25
|
-
import "
|
|
25
|
+
import "./random_width-CLMQG5Jn.js";
|
|
26
|
+
import "./register_all_kernels-COt6wLD0.js";
|
|
27
|
+
import "./dataset-BFFipD1c.js";
|
|
26
28
|
import "./ops/cpu/rope.js";
|
|
27
29
|
import "./ops/webgl/rope.js";
|
|
28
30
|
import "./ops/grads/rope.js";
|
|
@@ -41,13 +43,14 @@ import "./ops/cpu/normRMS.js";
|
|
|
41
43
|
import "./ops/webgl/normRMS.js";
|
|
42
44
|
import "./ops/grads/normRMS.js";
|
|
43
45
|
import "./ops/webgl/log.js";
|
|
44
|
-
import
|
|
46
|
+
import k from "./utilities/profile.js";
|
|
45
47
|
class a {
|
|
46
|
-
ee = new
|
|
48
|
+
ee = new c();
|
|
47
49
|
_config;
|
|
48
50
|
_model;
|
|
49
51
|
_tokeniser;
|
|
50
52
|
_status = "loading";
|
|
53
|
+
_memoryRequirements;
|
|
51
54
|
meta = {};
|
|
52
55
|
constructor(t, e) {
|
|
53
56
|
this._config = e?.config, this._tokeniser = t, this._model = e;
|
|
@@ -79,22 +82,26 @@ class a {
|
|
|
79
82
|
get ready() {
|
|
80
83
|
return this._status === "ready" && !!this._model && !!this._tokeniser && this.tokeniser.trained;
|
|
81
84
|
}
|
|
85
|
+
estimateTrainingMemoryUsage(t) {
|
|
86
|
+
const e = this._memoryRequirements ?? { perBatch: 0, gradients: 0 }, r = e.perBatch * t, o = e.gradients;
|
|
87
|
+
return r * 0.66 + o * 4;
|
|
88
|
+
}
|
|
82
89
|
setStatus(t) {
|
|
83
90
|
this._status !== t && (this._status = t, this.ee.emit("status", t));
|
|
84
91
|
}
|
|
85
92
|
saveModel(t) {
|
|
86
93
|
if (!this._model || !this._tokeniser)
|
|
87
94
|
throw new Error("Model or tokeniser is not initialized.");
|
|
88
|
-
return
|
|
95
|
+
return f(this._model, this._tokeniser, {
|
|
89
96
|
...t,
|
|
90
97
|
name: t?.name || this.meta.name
|
|
91
98
|
});
|
|
92
99
|
}
|
|
93
100
|
static loadModel(t) {
|
|
94
101
|
const e = new a();
|
|
95
|
-
return
|
|
96
|
-
e._model = r, e._tokeniser =
|
|
97
|
-
e.setStatus("ready"), e.ee.emit("loaded");
|
|
102
|
+
return u(t).then(({ model: r, tokeniser: o, name: s }) => {
|
|
103
|
+
e._model = r, e._tokeniser = o, e._config = r.config, s && (e.meta.name = s), e.setStatus("warmup"), m(r).then((i) => {
|
|
104
|
+
e._memoryRequirements = i, e.setStatus("ready"), e.ee.emit("loaded");
|
|
98
105
|
}).catch((i) => {
|
|
99
106
|
e.setStatus("error"), e.ee.emit("error", i);
|
|
100
107
|
});
|
|
@@ -103,10 +110,10 @@ class a {
|
|
|
103
110
|
}), e;
|
|
104
111
|
}
|
|
105
112
|
static create(t, e = {}) {
|
|
106
|
-
const r = { ...
|
|
107
|
-
return i.setStatus("warmup"), m(
|
|
108
|
-
i.tokeniser.trained ? (i.setStatus("ready"), i.ee.emit("loaded")) : (i.setStatus("awaitingTokens"), i.ee.emit("loaded"), i.tokeniser.once("trainStatus", (
|
|
109
|
-
|
|
113
|
+
const r = { ...d, ...e }, o = t === "char" ? new g(r.vocabSize) : new w(r.vocabSize), s = new l(r), i = new a(o, s);
|
|
114
|
+
return i.setStatus("warmup"), m(s).then((n) => {
|
|
115
|
+
i._memoryRequirements = n, i.tokeniser.trained ? (i.setStatus("ready"), i.ee.emit("loaded")) : (i.setStatus("awaitingTokens"), i.ee.emit("loaded"), i.tokeniser.once("trainStatus", (h) => {
|
|
116
|
+
h === "trained" && i.setStatus("ready");
|
|
110
117
|
}));
|
|
111
118
|
}).catch((n) => {
|
|
112
119
|
i.setStatus("error"), i.ee.emit("error", n);
|
|
@@ -122,7 +129,7 @@ class a {
|
|
|
122
129
|
if (t) {
|
|
123
130
|
if (!this._config)
|
|
124
131
|
throw new Error("Model is not initialized.");
|
|
125
|
-
this._config.layerConfig.profiler || (this._config.layerConfig.profiler = new
|
|
132
|
+
this._config.layerConfig.profiler || (this._config.layerConfig.profiler = new k());
|
|
126
133
|
} else
|
|
127
134
|
this._config?.layerConfig.profiler && (this._config.layerConfig.profiler = void 0);
|
|
128
135
|
}
|
|
@@ -134,11 +141,11 @@ class a {
|
|
|
134
141
|
trainer() {
|
|
135
142
|
if (!this._model || !this._tokeniser)
|
|
136
143
|
throw new Error("Model or tokeniser is not initialized.");
|
|
137
|
-
const t = new
|
|
144
|
+
const t = new _(this._model, this._tokeniser);
|
|
138
145
|
return t.on("start", () => this.setStatus("training")), t.on("stop", () => this.setStatus("ready")), t.on("log", async (e, r) => {
|
|
139
|
-
const
|
|
140
|
-
for (const
|
|
141
|
-
await
|
|
146
|
+
const o = this.ee.listeners("trainStep");
|
|
147
|
+
for (const s of o)
|
|
148
|
+
await s(e, r);
|
|
142
149
|
}), t;
|
|
143
150
|
}
|
|
144
151
|
train(t, e) {
|
|
@@ -153,7 +160,7 @@ class a {
|
|
|
153
160
|
generator() {
|
|
154
161
|
if (!this._model || !this._tokeniser)
|
|
155
162
|
throw new Error("model_or_tokeniser_not_initialized.");
|
|
156
|
-
const t = new
|
|
163
|
+
const t = new p(this._model, this._tokeniser);
|
|
157
164
|
return t.on("start", () => {
|
|
158
165
|
this.status === "ready" && this.setStatus("busy");
|
|
159
166
|
}), t.on("stop", () => {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { R as a } from "./random_width-
|
|
2
|
-
import "./index-
|
|
3
|
-
import { d as s } from "./tfjs_backend-BDb8r9qx.js";
|
|
1
|
+
import { R as a, d as s } from "./random_width-CLMQG5Jn.js";
|
|
2
|
+
import "./index-CamYe_M8.js";
|
|
4
3
|
import o from "./layers/BaseLayer.js";
|
|
5
|
-
import { v as m } from "./variable-
|
|
6
|
-
import { g as d } from "./gather-
|
|
4
|
+
import { v as m } from "./variable-CLVXjN7F.js";
|
|
5
|
+
import { g as d } from "./gather-DKtUaTtA.js";
|
|
7
6
|
/**
|
|
8
7
|
* @license
|
|
9
8
|
* Copyright 2018 Google LLC
|
|
@@ -13,16 +12,16 @@ import { g as d } from "./gather-DZCMHZuN.js";
|
|
|
13
12
|
* https://opensource.org/licenses/MIT.
|
|
14
13
|
* =============================================================================
|
|
15
14
|
*/
|
|
16
|
-
function n(
|
|
17
|
-
return new a(
|
|
15
|
+
function n(i) {
|
|
16
|
+
return new a(i);
|
|
18
17
|
}
|
|
19
|
-
class
|
|
18
|
+
class S extends o {
|
|
20
19
|
vocabSize;
|
|
21
20
|
embedDim;
|
|
22
21
|
initializer;
|
|
23
22
|
WEIGHTS;
|
|
24
|
-
constructor(t,
|
|
25
|
-
super(t, r), this.WEIGHTS =
|
|
23
|
+
constructor(t, e, r) {
|
|
24
|
+
super(t, r), this.WEIGHTS = e, this.vocabSize = t.gpt.vocabSize, this.embedDim = t.gpt.nEmbed, this.initializer = n({
|
|
26
25
|
mean: 0,
|
|
27
26
|
stddev: 0.02
|
|
28
27
|
}), this.addVariable(this.WEIGHTS, m(this.initializer.apply([this.vocabSize, this.embedDim]), !0));
|
|
@@ -34,11 +33,11 @@ class c extends o {
|
|
|
34
33
|
return s(t, this.getVariable(this.WEIGHTS).transpose());
|
|
35
34
|
}
|
|
36
35
|
// Dummy, should not be used.
|
|
37
|
-
forward(t,
|
|
38
|
-
return this.project(
|
|
36
|
+
forward(t, e) {
|
|
37
|
+
return this.project(e);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
export {
|
|
42
|
-
|
|
41
|
+
S as T,
|
|
43
42
|
n as r
|
|
44
43
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as c } from "./index-CamYe_M8.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC. All Rights Reserved.
|
|
@@ -21,28 +21,28 @@ function i(e, n) {
|
|
|
21
21
|
return !1;
|
|
22
22
|
return !0;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function a(e, n, t) {
|
|
25
25
|
const r = e.length + n.length, s = [];
|
|
26
26
|
let o = 0, f = 0;
|
|
27
27
|
for (let u = 0; u < r; u++)
|
|
28
28
|
t.indexOf(u) === -1 ? s.push(e[o++]) : s.push(n[f++]);
|
|
29
29
|
return s;
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function l(e, n) {
|
|
32
32
|
const t = [], r = e.length;
|
|
33
33
|
for (let o = 0; o < r; o++)
|
|
34
34
|
n.indexOf(o) === -1 && t.push(e[o]);
|
|
35
35
|
const s = n.map((o) => e[o]);
|
|
36
36
|
return [t, s];
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function h(e, n) {
|
|
39
39
|
const t = n.map((r) => 1);
|
|
40
|
-
return
|
|
40
|
+
return a(e, t, n);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function m(e, n, t) {
|
|
43
43
|
c(i(n, t), () => `${e} supports only inner-most axes for now. Got axes ${n} and rank-${t} input.`);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function d(e, n) {
|
|
46
46
|
if (i(e, n))
|
|
47
47
|
return null;
|
|
48
48
|
const t = [];
|
|
@@ -61,9 +61,11 @@ function x(e, n) {
|
|
|
61
61
|
}
|
|
62
62
|
export {
|
|
63
63
|
x as a,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
m as b,
|
|
65
|
+
l as c,
|
|
66
|
+
i as d,
|
|
67
|
+
h as e,
|
|
68
|
+
a as f,
|
|
69
|
+
d as g,
|
|
70
|
+
g as h
|
|
69
71
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as T } from "./reshape-
|
|
1
|
+
import { q as h, w as f, y as p, I as g, E as u, J as b } from "./index-CamYe_M8.js";
|
|
2
|
+
import { r as T } from "./reshape-C45vIIRU.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as s, k as a, x as p, I as i, E as l, K as f } from "./index-CamYe_M8.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -15,13 +15,13 @@ import { o as s, l as a, k as p, y as i, E as l, C as f } from "./index-bMBtI-WR
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
|
-
function h(
|
|
19
|
-
a(
|
|
20
|
-
const t = p(
|
|
21
|
-
if (t[0].dtype === "complex64" && t.forEach((
|
|
22
|
-
if (
|
|
18
|
+
function h(n, e = 0) {
|
|
19
|
+
a(n.length >= 1, () => "Pass at least one tensor to concat");
|
|
20
|
+
const t = p(n, "tensors", "concat", "string_or_numeric");
|
|
21
|
+
if (t[0].dtype === "complex64" && t.forEach((o) => {
|
|
22
|
+
if (o.dtype !== "complex64")
|
|
23
23
|
throw new Error(`Cannot concatenate complex64 tensors with a tensor
|
|
24
|
-
with dtype ${
|
|
24
|
+
with dtype ${o.dtype}. `);
|
|
25
25
|
}), t.length === 1)
|
|
26
26
|
return i(t[0]);
|
|
27
27
|
const r = t, c = { axis: e };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ab as S, T as h, ac as k, a as v, ad as o, ae as p, af as g, k as N, t as y } from "./index-CamYe_M8.js";
|
|
2
2
|
import { s as R } from "./index-C4L8Cm77.js";
|
|
3
|
-
import { s as $ } from "./stack-
|
|
4
|
-
import { t as B } from "./tensor-
|
|
3
|
+
import { s as $ } from "./stack-DgaoDmnF.js";
|
|
4
|
+
import { t as B } from "./tensor-CDz5x1mP.js";
|
|
5
5
|
/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -75,7 +75,7 @@ function I(s) {
|
|
|
75
75
|
}
|
|
76
76
|
function c(s) {
|
|
77
77
|
let t = !1;
|
|
78
|
-
if (
|
|
78
|
+
if (k().get("IS_BROWSER"))
|
|
79
79
|
t = s instanceof TextDecoder;
|
|
80
80
|
else {
|
|
81
81
|
const { StringDecoder: e } = require("string_decoder");
|
|
@@ -930,7 +930,7 @@ class T {
|
|
|
930
930
|
*/
|
|
931
931
|
batch(t, e = !0) {
|
|
932
932
|
const r = this;
|
|
933
|
-
|
|
933
|
+
N(t > 0, () => `batchSize needs to be positive, but it is
|
|
934
934
|
${t}`);
|
|
935
935
|
let n;
|
|
936
936
|
return this.size === 1 / 0 || this.size == null ? n = this.size : e ? n = Math.ceil(this.size / t) : n = Math.floor(this.size / t), u(async () => (await r.iterator()).columnMajorBatch(t, e, st), n);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as l, w as h, E as m, ag as p, y as c, ah as d, ai as g, k as u, T as V, aj as v, a7 as w, b as N } from "./index-CamYe_M8.js";
|
|
2
2
|
import { s as f } from "./index-C4L8Cm77.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
@@ -69,7 +69,7 @@ class T {
|
|
|
69
69
|
return t <= this.upper && t >= this.lower;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
class
|
|
72
|
+
class y {
|
|
73
73
|
constructor(t = 0, e = 1, s, n) {
|
|
74
74
|
if (this.canReturnFloat = () => this.dtype == null || this.dtype === "float32", this.min = t, this.range = e - t, this.dtype = s, n == null && (n = Math.random()), typeof n == "number" && (n = n.toString()), !this.canReturnFloat() && this.range <= 1)
|
|
75
75
|
throw new Error(`The difference between ${t} - ${e} <= 1 and dtype is not float`);
|
|
@@ -98,7 +98,7 @@ class $ {
|
|
|
98
98
|
* limitations under the License.
|
|
99
99
|
* =============================================================================
|
|
100
100
|
*/
|
|
101
|
-
function
|
|
101
|
+
function $(r, t = 0, e = 1, s, n) {
|
|
102
102
|
if (c(r), s != null && s === "bool")
|
|
103
103
|
throw new Error(`Unsupported data type ${s}`);
|
|
104
104
|
const o = new T(t, e, s, !1, n), a = d(r, s);
|
|
@@ -106,7 +106,7 @@ function y(r, t = 0, e = 1, s, n) {
|
|
|
106
106
|
a.values[i] = o.nextValue();
|
|
107
107
|
return a.toTensor();
|
|
108
108
|
}
|
|
109
|
-
const _ = /* @__PURE__ */ l({ randomNormal_:
|
|
109
|
+
const _ = /* @__PURE__ */ l({ randomNormal_: $ });
|
|
110
110
|
/**
|
|
111
111
|
* @license
|
|
112
112
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -125,7 +125,7 @@ const _ = /* @__PURE__ */ l({ randomNormal_: y });
|
|
|
125
125
|
*/
|
|
126
126
|
function M(r, t = 0, e = 1, s = "float32", n) {
|
|
127
127
|
c(r);
|
|
128
|
-
const o = d(r, s), a = new
|
|
128
|
+
const o = d(r, s), a = new y(t, e, null, n);
|
|
129
129
|
for (let i = 0; i < o.values.length; i++)
|
|
130
130
|
o.values[i] = a.nextValue();
|
|
131
131
|
return o.toTensor();
|
|
@@ -180,14 +180,14 @@ function R(r, t, e, s) {
|
|
|
180
180
|
const n = h(r, "x", "dropout");
|
|
181
181
|
if (u(n.dtype === "float32", () => `x has to be a floating point tensor since it's going to be scaled, but got a ${n.dtype} tensor instead.`), u(t >= 0 && t < 1, () => `rate must be a float in the range [0, 1), but got ${t}.`), t === 0)
|
|
182
182
|
return r instanceof V ? n.clone() : n;
|
|
183
|
-
const o = E(n, e), a = 1 - t, i = v(x(
|
|
184
|
-
return
|
|
183
|
+
const o = E(n, e), a = 1 - t, i = v(x(w(D(o, 0, 1, "float32", s), a)), a);
|
|
184
|
+
return N(n, i);
|
|
185
185
|
}
|
|
186
|
-
const
|
|
186
|
+
const q = /* @__PURE__ */ l({ dropout_: R });
|
|
187
187
|
export {
|
|
188
188
|
T as M,
|
|
189
189
|
D as a,
|
|
190
|
-
|
|
190
|
+
q as d,
|
|
191
191
|
x as f,
|
|
192
192
|
_ as r
|
|
193
193
|
};
|