wasm-bhtsne 0.3.1 → 0.3.2
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 +8 -3
- package/wasm_bhtsne.d.ts +29 -62
- package/wasm_bhtsne.js +530 -4
- package/wasm_bhtsne_bg.wasm +0 -0
- package/wasm_bhtsne_bg.js +0 -582
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"lv291 <baiunco291@proton.me>"
|
|
5
5
|
],
|
|
6
6
|
"description": "Exact and Barnes-Hut implementations of t-SNE in wasm",
|
|
7
|
-
"version": "0.3.
|
|
7
|
+
"version": "0.3.2",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -13,13 +13,18 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
"wasm_bhtsne_bg.wasm",
|
|
15
15
|
"wasm_bhtsne.js",
|
|
16
|
-
"wasm_bhtsne_bg.js",
|
|
17
16
|
"wasm_bhtsne.d.ts"
|
|
18
17
|
],
|
|
19
18
|
"module": "wasm_bhtsne.js",
|
|
20
19
|
"types": "wasm_bhtsne.d.ts",
|
|
21
20
|
"sideEffects": [
|
|
22
|
-
"./wasm_bhtsne.js",
|
|
23
21
|
"./snippets/*"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"tsne",
|
|
25
|
+
"data-visualization",
|
|
26
|
+
"data-analysis",
|
|
27
|
+
"Barnes-Hut",
|
|
28
|
+
"machine-learning"
|
|
24
29
|
]
|
|
25
30
|
}
|
package/wasm_bhtsne.d.ts
CHANGED
|
@@ -31,74 +31,41 @@ export class tSNE {
|
|
|
31
31
|
*/
|
|
32
32
|
barnes_hut(epochs: number): Array<any>;
|
|
33
33
|
/**
|
|
34
|
-
* Returns the computed embedding.
|
|
35
|
-
* @returns {Array<any>}
|
|
36
|
-
*/
|
|
37
|
-
embedding(): Array<any>;
|
|
38
|
-
/**
|
|
39
|
-
* Sets a new value for the embedding dimension.
|
|
40
|
-
*
|
|
41
|
-
* # Arguments
|
|
42
|
-
*
|
|
43
|
-
* `embedding_dim` - new value for the embedding space dimensionality.
|
|
44
|
-
*/
|
|
45
|
-
embedding_dim: number;
|
|
46
|
-
/**
|
|
47
|
-
* Sets a new final momentum.
|
|
48
|
-
*
|
|
49
|
-
* # Arguments
|
|
50
|
-
*
|
|
51
|
-
* `final_momentum` - new value for the final momentum.
|
|
52
|
-
*/
|
|
53
|
-
final_momentum: number;
|
|
54
|
-
/**
|
|
55
|
-
* Sets a new learning rate.
|
|
56
|
-
*
|
|
57
|
-
* # Arguments
|
|
58
|
-
*
|
|
59
|
-
* `learning_rate` - new value for the learning rate.
|
|
60
|
-
*/
|
|
61
|
-
learning_rate: number;
|
|
62
|
-
/**
|
|
63
|
-
* Sets a new momentum.
|
|
64
|
-
*
|
|
65
|
-
* # Arguments
|
|
66
|
-
*
|
|
67
|
-
* `momentum` - new value for the momentum.
|
|
68
34
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
35
|
+
theta: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
39
|
+
|
|
40
|
+
export interface InitOutput {
|
|
41
|
+
readonly memory: WebAssembly.Memory;
|
|
42
|
+
readonly __wbg_tsne_free: (a: number) => void;
|
|
43
|
+
readonly tsne_new: (a: number) => number;
|
|
44
|
+
readonly tsne_barnes_hut: (a: number, b: number) => number;
|
|
45
|
+
readonly tsne_set_theta: (a: number, b: number) => void;
|
|
46
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
47
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
48
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
49
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
79
53
|
/**
|
|
80
|
-
*
|
|
54
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
55
|
+
* a precompiled `WebAssembly.Module`.
|
|
81
56
|
*
|
|
82
|
-
*
|
|
57
|
+
* @param {SyncInitInput} module
|
|
83
58
|
*
|
|
84
|
-
*
|
|
85
|
-
* kernels, is set in such a way that the perplexity of each the conditional distribution *Pi*
|
|
86
|
-
* equals a predefined perplexity *u*.
|
|
87
|
-
*
|
|
88
|
-
* A good value for perplexity lies between 5.0 and 50.0.
|
|
59
|
+
* @returns {InitOutput}
|
|
89
60
|
*/
|
|
90
|
-
|
|
61
|
+
export function initSync(module: SyncInitInput): InitOutput;
|
|
62
|
+
|
|
91
63
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* of the P distribution are multiplied by a factor equal to `12.0`.
|
|
64
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
65
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
95
66
|
*
|
|
96
|
-
*
|
|
67
|
+
* @param {InitInput | Promise<InitInput>} module_or_path
|
|
97
68
|
*
|
|
98
|
-
*
|
|
69
|
+
* @returns {Promise<InitOutput>}
|
|
99
70
|
*/
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
*/
|
|
103
|
-
theta: number;
|
|
104
|
-
}
|
|
71
|
+
export default function __wbg_init (module_or_path?: InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/wasm_bhtsne.js
CHANGED
|
@@ -1,4 +1,530 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
const heap = new Array(128).fill(undefined);
|
|
4
|
+
|
|
5
|
+
heap.push(undefined, null, true, false);
|
|
6
|
+
|
|
7
|
+
function getObject(idx) { return heap[idx]; }
|
|
8
|
+
|
|
9
|
+
let heap_next = heap.length;
|
|
10
|
+
|
|
11
|
+
function dropObject(idx) {
|
|
12
|
+
if (idx < 132) return;
|
|
13
|
+
heap[idx] = heap_next;
|
|
14
|
+
heap_next = idx;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function takeObject(idx) {
|
|
18
|
+
const ret = getObject(idx);
|
|
19
|
+
dropObject(idx);
|
|
20
|
+
return ret;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isLikeNone(x) {
|
|
24
|
+
return x === undefined || x === null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let cachedFloat64Memory0 = null;
|
|
28
|
+
|
|
29
|
+
function getFloat64Memory0() {
|
|
30
|
+
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
|
|
31
|
+
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
|
|
32
|
+
}
|
|
33
|
+
return cachedFloat64Memory0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let cachedInt32Memory0 = null;
|
|
37
|
+
|
|
38
|
+
function getInt32Memory0() {
|
|
39
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
40
|
+
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
41
|
+
}
|
|
42
|
+
return cachedInt32Memory0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
46
|
+
|
|
47
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
48
|
+
|
|
49
|
+
let cachedUint8Memory0 = null;
|
|
50
|
+
|
|
51
|
+
function getUint8Memory0() {
|
|
52
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
53
|
+
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
54
|
+
}
|
|
55
|
+
return cachedUint8Memory0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getStringFromWasm0(ptr, len) {
|
|
59
|
+
ptr = ptr >>> 0;
|
|
60
|
+
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function addHeapObject(obj) {
|
|
64
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
65
|
+
const idx = heap_next;
|
|
66
|
+
heap_next = heap[idx];
|
|
67
|
+
|
|
68
|
+
heap[idx] = obj;
|
|
69
|
+
return idx;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function debugString(val) {
|
|
73
|
+
// primitive types
|
|
74
|
+
const type = typeof val;
|
|
75
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
76
|
+
return `${val}`;
|
|
77
|
+
}
|
|
78
|
+
if (type == 'string') {
|
|
79
|
+
return `"${val}"`;
|
|
80
|
+
}
|
|
81
|
+
if (type == 'symbol') {
|
|
82
|
+
const description = val.description;
|
|
83
|
+
if (description == null) {
|
|
84
|
+
return 'Symbol';
|
|
85
|
+
} else {
|
|
86
|
+
return `Symbol(${description})`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (type == 'function') {
|
|
90
|
+
const name = val.name;
|
|
91
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
92
|
+
return `Function(${name})`;
|
|
93
|
+
} else {
|
|
94
|
+
return 'Function';
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// objects
|
|
98
|
+
if (Array.isArray(val)) {
|
|
99
|
+
const length = val.length;
|
|
100
|
+
let debug = '[';
|
|
101
|
+
if (length > 0) {
|
|
102
|
+
debug += debugString(val[0]);
|
|
103
|
+
}
|
|
104
|
+
for(let i = 1; i < length; i++) {
|
|
105
|
+
debug += ', ' + debugString(val[i]);
|
|
106
|
+
}
|
|
107
|
+
debug += ']';
|
|
108
|
+
return debug;
|
|
109
|
+
}
|
|
110
|
+
// Test for built-in
|
|
111
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
112
|
+
let className;
|
|
113
|
+
if (builtInMatches.length > 1) {
|
|
114
|
+
className = builtInMatches[1];
|
|
115
|
+
} else {
|
|
116
|
+
// Failed to match the standard '[object ClassName]'
|
|
117
|
+
return toString.call(val);
|
|
118
|
+
}
|
|
119
|
+
if (className == 'Object') {
|
|
120
|
+
// we're a user defined class or Object
|
|
121
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
122
|
+
// easier than looping through ownProperties of `val`.
|
|
123
|
+
try {
|
|
124
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
125
|
+
} catch (_) {
|
|
126
|
+
return 'Object';
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// errors
|
|
130
|
+
if (val instanceof Error) {
|
|
131
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
132
|
+
}
|
|
133
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
134
|
+
return className;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
let WASM_VECTOR_LEN = 0;
|
|
138
|
+
|
|
139
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
140
|
+
|
|
141
|
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
142
|
+
? function (arg, view) {
|
|
143
|
+
return cachedTextEncoder.encodeInto(arg, view);
|
|
144
|
+
}
|
|
145
|
+
: function (arg, view) {
|
|
146
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
147
|
+
view.set(buf);
|
|
148
|
+
return {
|
|
149
|
+
read: arg.length,
|
|
150
|
+
written: buf.length
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
155
|
+
|
|
156
|
+
if (realloc === undefined) {
|
|
157
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
158
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
159
|
+
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
160
|
+
WASM_VECTOR_LEN = buf.length;
|
|
161
|
+
return ptr;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
let len = arg.length;
|
|
165
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
166
|
+
|
|
167
|
+
const mem = getUint8Memory0();
|
|
168
|
+
|
|
169
|
+
let offset = 0;
|
|
170
|
+
|
|
171
|
+
for (; offset < len; offset++) {
|
|
172
|
+
const code = arg.charCodeAt(offset);
|
|
173
|
+
if (code > 0x7F) break;
|
|
174
|
+
mem[ptr + offset] = code;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (offset !== len) {
|
|
178
|
+
if (offset !== 0) {
|
|
179
|
+
arg = arg.slice(offset);
|
|
180
|
+
}
|
|
181
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
182
|
+
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
183
|
+
const ret = encodeString(arg, view);
|
|
184
|
+
|
|
185
|
+
offset += ret.written;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
WASM_VECTOR_LEN = offset;
|
|
189
|
+
return ptr;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function handleError(f, args) {
|
|
193
|
+
try {
|
|
194
|
+
return f.apply(this, args);
|
|
195
|
+
} catch (e) {
|
|
196
|
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* t-distributed stochastic neighbor embedding. Provides a parallel implementation of both the
|
|
201
|
+
* exact version of the algorithm and the tree accelerated one leveraging space partitioning trees.
|
|
202
|
+
*/
|
|
203
|
+
export class tSNE {
|
|
204
|
+
|
|
205
|
+
static __wrap(ptr) {
|
|
206
|
+
ptr = ptr >>> 0;
|
|
207
|
+
const obj = Object.create(tSNE.prototype);
|
|
208
|
+
obj.__wbg_ptr = ptr;
|
|
209
|
+
|
|
210
|
+
return obj;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
__destroy_into_raw() {
|
|
214
|
+
const ptr = this.__wbg_ptr;
|
|
215
|
+
this.__wbg_ptr = 0;
|
|
216
|
+
|
|
217
|
+
return ptr;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
free() {
|
|
221
|
+
const ptr = this.__destroy_into_raw();
|
|
222
|
+
wasm.__wbg_tsne_free(ptr);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* @param {Array<any>} vectors
|
|
226
|
+
*/
|
|
227
|
+
constructor(vectors) {
|
|
228
|
+
const ret = wasm.tsne_new(addHeapObject(vectors));
|
|
229
|
+
return tSNE.__wrap(ret);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Performs a parallel Barnes-Hut approximation of the t-SNE algorithm.
|
|
233
|
+
*
|
|
234
|
+
* # Arguments
|
|
235
|
+
*
|
|
236
|
+
* * `theta` - determines the accuracy of the approximation. Must be **strictly greater than
|
|
237
|
+
* 0.0**. Large values for θ increase the speed of the algorithm but decrease its accuracy.
|
|
238
|
+
* For small values of θ it is less probable that a cell in the space partitioning tree will
|
|
239
|
+
* be treated as a single point. For θ equal to 0.0 the method degenerates in the exact
|
|
240
|
+
* version.
|
|
241
|
+
*
|
|
242
|
+
* * `metric_f` - metric function.
|
|
243
|
+
*
|
|
244
|
+
*
|
|
245
|
+
* **Do note that** `metric_f` **must be a metric distance**, i.e. it must
|
|
246
|
+
* satisfy the [triangle inequality](https://en.wikipedia.org/wiki/Triangle_inequality).
|
|
247
|
+
* @param {number} epochs
|
|
248
|
+
* @returns {Array<any>}
|
|
249
|
+
*/
|
|
250
|
+
barnes_hut(epochs) {
|
|
251
|
+
const ret = wasm.tsne_barnes_hut(this.__wbg_ptr, epochs);
|
|
252
|
+
return takeObject(ret);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* @param {number} theta
|
|
256
|
+
*/
|
|
257
|
+
set theta(theta) {
|
|
258
|
+
wasm.tsne_set_theta(this.__wbg_ptr, theta);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async function __wbg_load(module, imports) {
|
|
263
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
264
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
265
|
+
try {
|
|
266
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
267
|
+
|
|
268
|
+
} catch (e) {
|
|
269
|
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
|
270
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
271
|
+
|
|
272
|
+
} else {
|
|
273
|
+
throw e;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const bytes = await module.arrayBuffer();
|
|
279
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
280
|
+
|
|
281
|
+
} else {
|
|
282
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
283
|
+
|
|
284
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
285
|
+
return { instance, module };
|
|
286
|
+
|
|
287
|
+
} else {
|
|
288
|
+
return instance;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function __wbg_get_imports() {
|
|
294
|
+
const imports = {};
|
|
295
|
+
imports.wbg = {};
|
|
296
|
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
297
|
+
takeObject(arg0);
|
|
298
|
+
};
|
|
299
|
+
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
300
|
+
const obj = getObject(arg1);
|
|
301
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
302
|
+
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
|
303
|
+
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
304
|
+
};
|
|
305
|
+
imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
|
|
306
|
+
const ret = new Error();
|
|
307
|
+
return addHeapObject(ret);
|
|
308
|
+
};
|
|
309
|
+
imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
310
|
+
const ret = getObject(arg1).stack;
|
|
311
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
312
|
+
const len1 = WASM_VECTOR_LEN;
|
|
313
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
314
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
315
|
+
};
|
|
316
|
+
imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
317
|
+
let deferred0_0;
|
|
318
|
+
let deferred0_1;
|
|
319
|
+
try {
|
|
320
|
+
deferred0_0 = arg0;
|
|
321
|
+
deferred0_1 = arg1;
|
|
322
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
323
|
+
} finally {
|
|
324
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
imports.wbg.__wbg_randomFillSync_dc1e9a60c158336d = function() { return handleError(function (arg0, arg1) {
|
|
328
|
+
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
329
|
+
}, arguments) };
|
|
330
|
+
imports.wbg.__wbg_getRandomValues_37fa2ca9e4e07fab = function() { return handleError(function (arg0, arg1) {
|
|
331
|
+
getObject(arg0).getRandomValues(getObject(arg1));
|
|
332
|
+
}, arguments) };
|
|
333
|
+
imports.wbg.__wbg_crypto_c48a774b022d20ac = function(arg0) {
|
|
334
|
+
const ret = getObject(arg0).crypto;
|
|
335
|
+
return addHeapObject(ret);
|
|
336
|
+
};
|
|
337
|
+
imports.wbg.__wbindgen_is_object = function(arg0) {
|
|
338
|
+
const val = getObject(arg0);
|
|
339
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
340
|
+
return ret;
|
|
341
|
+
};
|
|
342
|
+
imports.wbg.__wbg_process_298734cf255a885d = function(arg0) {
|
|
343
|
+
const ret = getObject(arg0).process;
|
|
344
|
+
return addHeapObject(ret);
|
|
345
|
+
};
|
|
346
|
+
imports.wbg.__wbg_versions_e2e78e134e3e5d01 = function(arg0) {
|
|
347
|
+
const ret = getObject(arg0).versions;
|
|
348
|
+
return addHeapObject(ret);
|
|
349
|
+
};
|
|
350
|
+
imports.wbg.__wbg_node_1cd7a5d853dbea79 = function(arg0) {
|
|
351
|
+
const ret = getObject(arg0).node;
|
|
352
|
+
return addHeapObject(ret);
|
|
353
|
+
};
|
|
354
|
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
|
355
|
+
const ret = typeof(getObject(arg0)) === 'string';
|
|
356
|
+
return ret;
|
|
357
|
+
};
|
|
358
|
+
imports.wbg.__wbg_require_8f08ceecec0f4fee = function() { return handleError(function () {
|
|
359
|
+
const ret = module.require;
|
|
360
|
+
return addHeapObject(ret);
|
|
361
|
+
}, arguments) };
|
|
362
|
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
|
363
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
364
|
+
return addHeapObject(ret);
|
|
365
|
+
};
|
|
366
|
+
imports.wbg.__wbg_msCrypto_bcb970640f50a1e8 = function(arg0) {
|
|
367
|
+
const ret = getObject(arg0).msCrypto;
|
|
368
|
+
return addHeapObject(ret);
|
|
369
|
+
};
|
|
370
|
+
imports.wbg.__wbg_get_44be0491f933a435 = function(arg0, arg1) {
|
|
371
|
+
const ret = getObject(arg0)[arg1 >>> 0];
|
|
372
|
+
return addHeapObject(ret);
|
|
373
|
+
};
|
|
374
|
+
imports.wbg.__wbg_length_fff51ee6522a1a18 = function(arg0) {
|
|
375
|
+
const ret = getObject(arg0).length;
|
|
376
|
+
return ret;
|
|
377
|
+
};
|
|
378
|
+
imports.wbg.__wbg_new_898a68150f225f2e = function() {
|
|
379
|
+
const ret = new Array();
|
|
380
|
+
return addHeapObject(ret);
|
|
381
|
+
};
|
|
382
|
+
imports.wbg.__wbindgen_is_function = function(arg0) {
|
|
383
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
384
|
+
return ret;
|
|
385
|
+
};
|
|
386
|
+
imports.wbg.__wbg_newnoargs_581967eacc0e2604 = function(arg0, arg1) {
|
|
387
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
388
|
+
return addHeapObject(ret);
|
|
389
|
+
};
|
|
390
|
+
imports.wbg.__wbg_call_cb65541d95d71282 = function() { return handleError(function (arg0, arg1) {
|
|
391
|
+
const ret = getObject(arg0).call(getObject(arg1));
|
|
392
|
+
return addHeapObject(ret);
|
|
393
|
+
}, arguments) };
|
|
394
|
+
imports.wbg.__wbg_self_1ff1d729e9aae938 = function() { return handleError(function () {
|
|
395
|
+
const ret = self.self;
|
|
396
|
+
return addHeapObject(ret);
|
|
397
|
+
}, arguments) };
|
|
398
|
+
imports.wbg.__wbg_window_5f4faef6c12b79ec = function() { return handleError(function () {
|
|
399
|
+
const ret = window.window;
|
|
400
|
+
return addHeapObject(ret);
|
|
401
|
+
}, arguments) };
|
|
402
|
+
imports.wbg.__wbg_globalThis_1d39714405582d3c = function() { return handleError(function () {
|
|
403
|
+
const ret = globalThis.globalThis;
|
|
404
|
+
return addHeapObject(ret);
|
|
405
|
+
}, arguments) };
|
|
406
|
+
imports.wbg.__wbg_global_651f05c6a0944d1c = function() { return handleError(function () {
|
|
407
|
+
const ret = global.global;
|
|
408
|
+
return addHeapObject(ret);
|
|
409
|
+
}, arguments) };
|
|
410
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
411
|
+
const ret = getObject(arg0) === undefined;
|
|
412
|
+
return ret;
|
|
413
|
+
};
|
|
414
|
+
imports.wbg.__wbg_isArray_4c24b343cb13cfb1 = function(arg0) {
|
|
415
|
+
const ret = Array.isArray(getObject(arg0));
|
|
416
|
+
return ret;
|
|
417
|
+
};
|
|
418
|
+
imports.wbg.__wbg_push_ca1c26067ef907ac = function(arg0, arg1) {
|
|
419
|
+
const ret = getObject(arg0).push(getObject(arg1));
|
|
420
|
+
return ret;
|
|
421
|
+
};
|
|
422
|
+
imports.wbg.__wbg_call_01734de55d61e11d = function() { return handleError(function (arg0, arg1, arg2) {
|
|
423
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
424
|
+
return addHeapObject(ret);
|
|
425
|
+
}, arguments) };
|
|
426
|
+
imports.wbg.__wbg_buffer_085ec1f694018c4f = function(arg0) {
|
|
427
|
+
const ret = getObject(arg0).buffer;
|
|
428
|
+
return addHeapObject(ret);
|
|
429
|
+
};
|
|
430
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_6da8e527659b86aa = function(arg0, arg1, arg2) {
|
|
431
|
+
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
432
|
+
return addHeapObject(ret);
|
|
433
|
+
};
|
|
434
|
+
imports.wbg.__wbg_new_8125e318e6245eed = function(arg0) {
|
|
435
|
+
const ret = new Uint8Array(getObject(arg0));
|
|
436
|
+
return addHeapObject(ret);
|
|
437
|
+
};
|
|
438
|
+
imports.wbg.__wbg_set_5cf90238115182c3 = function(arg0, arg1, arg2) {
|
|
439
|
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
440
|
+
};
|
|
441
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_69193e31c844b792 = function(arg0, arg1, arg2) {
|
|
442
|
+
const ret = new Float32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
443
|
+
return addHeapObject(ret);
|
|
444
|
+
};
|
|
445
|
+
imports.wbg.__wbg_new_d086a66d1c264b3f = function(arg0) {
|
|
446
|
+
const ret = new Float32Array(getObject(arg0));
|
|
447
|
+
return addHeapObject(ret);
|
|
448
|
+
};
|
|
449
|
+
imports.wbg.__wbg_newwithlength_e5d69174d6984cd7 = function(arg0) {
|
|
450
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
451
|
+
return addHeapObject(ret);
|
|
452
|
+
};
|
|
453
|
+
imports.wbg.__wbg_subarray_13db269f57aa838d = function(arg0, arg1, arg2) {
|
|
454
|
+
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
455
|
+
return addHeapObject(ret);
|
|
456
|
+
};
|
|
457
|
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
458
|
+
const ret = getObject(arg0);
|
|
459
|
+
return addHeapObject(ret);
|
|
460
|
+
};
|
|
461
|
+
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
462
|
+
const ret = debugString(getObject(arg1));
|
|
463
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
464
|
+
const len1 = WASM_VECTOR_LEN;
|
|
465
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
466
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
467
|
+
};
|
|
468
|
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
|
469
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
470
|
+
};
|
|
471
|
+
imports.wbg.__wbindgen_memory = function() {
|
|
472
|
+
const ret = wasm.memory;
|
|
473
|
+
return addHeapObject(ret);
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
return imports;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function __wbg_init_memory(imports, maybe_memory) {
|
|
480
|
+
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function __wbg_finalize_init(instance, module) {
|
|
484
|
+
wasm = instance.exports;
|
|
485
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
486
|
+
cachedFloat64Memory0 = null;
|
|
487
|
+
cachedInt32Memory0 = null;
|
|
488
|
+
cachedUint8Memory0 = null;
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
return wasm;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function initSync(module) {
|
|
495
|
+
if (wasm !== undefined) return wasm;
|
|
496
|
+
|
|
497
|
+
const imports = __wbg_get_imports();
|
|
498
|
+
|
|
499
|
+
__wbg_init_memory(imports);
|
|
500
|
+
|
|
501
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
502
|
+
module = new WebAssembly.Module(module);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
506
|
+
|
|
507
|
+
return __wbg_finalize_init(instance, module);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
async function __wbg_init(input) {
|
|
511
|
+
if (wasm !== undefined) return wasm;
|
|
512
|
+
|
|
513
|
+
if (typeof input === 'undefined') {
|
|
514
|
+
input = new URL('wasm_bhtsne_bg.wasm', import.meta.url);
|
|
515
|
+
}
|
|
516
|
+
const imports = __wbg_get_imports();
|
|
517
|
+
|
|
518
|
+
if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
|
|
519
|
+
input = fetch(input);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
__wbg_init_memory(imports);
|
|
523
|
+
|
|
524
|
+
const { instance, module } = await __wbg_load(await input, imports);
|
|
525
|
+
|
|
526
|
+
return __wbg_finalize_init(instance, module);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
export { initSync }
|
|
530
|
+
export default __wbg_init;
|
package/wasm_bhtsne_bg.wasm
CHANGED
|
Binary file
|
package/wasm_bhtsne_bg.js
DELETED
|
@@ -1,582 +0,0 @@
|
|
|
1
|
-
let wasm;
|
|
2
|
-
export function __wbg_set_wasm(val) {
|
|
3
|
-
wasm = val;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const heap = new Array(128).fill(undefined);
|
|
8
|
-
|
|
9
|
-
heap.push(undefined, null, true, false);
|
|
10
|
-
|
|
11
|
-
function getObject(idx) { return heap[idx]; }
|
|
12
|
-
|
|
13
|
-
let heap_next = heap.length;
|
|
14
|
-
|
|
15
|
-
function dropObject(idx) {
|
|
16
|
-
if (idx < 132) return;
|
|
17
|
-
heap[idx] = heap_next;
|
|
18
|
-
heap_next = idx;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function takeObject(idx) {
|
|
22
|
-
const ret = getObject(idx);
|
|
23
|
-
dropObject(idx);
|
|
24
|
-
return ret;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function isLikeNone(x) {
|
|
28
|
-
return x === undefined || x === null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let cachedFloat64Memory0 = null;
|
|
32
|
-
|
|
33
|
-
function getFloat64Memory0() {
|
|
34
|
-
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
|
|
35
|
-
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
|
|
36
|
-
}
|
|
37
|
-
return cachedFloat64Memory0;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
let cachedInt32Memory0 = null;
|
|
41
|
-
|
|
42
|
-
function getInt32Memory0() {
|
|
43
|
-
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
44
|
-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
45
|
-
}
|
|
46
|
-
return cachedInt32Memory0;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
50
|
-
|
|
51
|
-
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
52
|
-
|
|
53
|
-
cachedTextDecoder.decode();
|
|
54
|
-
|
|
55
|
-
let cachedUint8Memory0 = null;
|
|
56
|
-
|
|
57
|
-
function getUint8Memory0() {
|
|
58
|
-
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
59
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
60
|
-
}
|
|
61
|
-
return cachedUint8Memory0;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function getStringFromWasm0(ptr, len) {
|
|
65
|
-
ptr = ptr >>> 0;
|
|
66
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function addHeapObject(obj) {
|
|
70
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
71
|
-
const idx = heap_next;
|
|
72
|
-
heap_next = heap[idx];
|
|
73
|
-
|
|
74
|
-
heap[idx] = obj;
|
|
75
|
-
return idx;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function debugString(val) {
|
|
79
|
-
// primitive types
|
|
80
|
-
const type = typeof val;
|
|
81
|
-
if (type == 'number' || type == 'boolean' || val == null) {
|
|
82
|
-
return `${val}`;
|
|
83
|
-
}
|
|
84
|
-
if (type == 'string') {
|
|
85
|
-
return `"${val}"`;
|
|
86
|
-
}
|
|
87
|
-
if (type == 'symbol') {
|
|
88
|
-
const description = val.description;
|
|
89
|
-
if (description == null) {
|
|
90
|
-
return 'Symbol';
|
|
91
|
-
} else {
|
|
92
|
-
return `Symbol(${description})`;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (type == 'function') {
|
|
96
|
-
const name = val.name;
|
|
97
|
-
if (typeof name == 'string' && name.length > 0) {
|
|
98
|
-
return `Function(${name})`;
|
|
99
|
-
} else {
|
|
100
|
-
return 'Function';
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// objects
|
|
104
|
-
if (Array.isArray(val)) {
|
|
105
|
-
const length = val.length;
|
|
106
|
-
let debug = '[';
|
|
107
|
-
if (length > 0) {
|
|
108
|
-
debug += debugString(val[0]);
|
|
109
|
-
}
|
|
110
|
-
for(let i = 1; i < length; i++) {
|
|
111
|
-
debug += ', ' + debugString(val[i]);
|
|
112
|
-
}
|
|
113
|
-
debug += ']';
|
|
114
|
-
return debug;
|
|
115
|
-
}
|
|
116
|
-
// Test for built-in
|
|
117
|
-
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
118
|
-
let className;
|
|
119
|
-
if (builtInMatches.length > 1) {
|
|
120
|
-
className = builtInMatches[1];
|
|
121
|
-
} else {
|
|
122
|
-
// Failed to match the standard '[object ClassName]'
|
|
123
|
-
return toString.call(val);
|
|
124
|
-
}
|
|
125
|
-
if (className == 'Object') {
|
|
126
|
-
// we're a user defined class or Object
|
|
127
|
-
// JSON.stringify avoids problems with cycles, and is generally much
|
|
128
|
-
// easier than looping through ownProperties of `val`.
|
|
129
|
-
try {
|
|
130
|
-
return 'Object(' + JSON.stringify(val) + ')';
|
|
131
|
-
} catch (_) {
|
|
132
|
-
return 'Object';
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
// errors
|
|
136
|
-
if (val instanceof Error) {
|
|
137
|
-
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
138
|
-
}
|
|
139
|
-
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
140
|
-
return className;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
let WASM_VECTOR_LEN = 0;
|
|
144
|
-
|
|
145
|
-
const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
146
|
-
|
|
147
|
-
let cachedTextEncoder = new lTextEncoder('utf-8');
|
|
148
|
-
|
|
149
|
-
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
150
|
-
? function (arg, view) {
|
|
151
|
-
return cachedTextEncoder.encodeInto(arg, view);
|
|
152
|
-
}
|
|
153
|
-
: function (arg, view) {
|
|
154
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
155
|
-
view.set(buf);
|
|
156
|
-
return {
|
|
157
|
-
read: arg.length,
|
|
158
|
-
written: buf.length
|
|
159
|
-
};
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
163
|
-
|
|
164
|
-
if (realloc === undefined) {
|
|
165
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
166
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
167
|
-
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
168
|
-
WASM_VECTOR_LEN = buf.length;
|
|
169
|
-
return ptr;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
let len = arg.length;
|
|
173
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
174
|
-
|
|
175
|
-
const mem = getUint8Memory0();
|
|
176
|
-
|
|
177
|
-
let offset = 0;
|
|
178
|
-
|
|
179
|
-
for (; offset < len; offset++) {
|
|
180
|
-
const code = arg.charCodeAt(offset);
|
|
181
|
-
if (code > 0x7F) break;
|
|
182
|
-
mem[ptr + offset] = code;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (offset !== len) {
|
|
186
|
-
if (offset !== 0) {
|
|
187
|
-
arg = arg.slice(offset);
|
|
188
|
-
}
|
|
189
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
190
|
-
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
191
|
-
const ret = encodeString(arg, view);
|
|
192
|
-
|
|
193
|
-
offset += ret.written;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
WASM_VECTOR_LEN = offset;
|
|
197
|
-
return ptr;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function handleError(f, args) {
|
|
201
|
-
try {
|
|
202
|
-
return f.apply(this, args);
|
|
203
|
-
} catch (e) {
|
|
204
|
-
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* t-distributed stochastic neighbor embedding. Provides a parallel implementation of both the
|
|
209
|
-
* exact version of the algorithm and the tree accelerated one leveraging space partitioning trees.
|
|
210
|
-
*/
|
|
211
|
-
export class tSNE {
|
|
212
|
-
|
|
213
|
-
static __wrap(ptr) {
|
|
214
|
-
ptr = ptr >>> 0;
|
|
215
|
-
const obj = Object.create(tSNE.prototype);
|
|
216
|
-
obj.__wbg_ptr = ptr;
|
|
217
|
-
|
|
218
|
-
return obj;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
__destroy_into_raw() {
|
|
222
|
-
const ptr = this.__wbg_ptr;
|
|
223
|
-
this.__wbg_ptr = 0;
|
|
224
|
-
|
|
225
|
-
return ptr;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
free() {
|
|
229
|
-
const ptr = this.__destroy_into_raw();
|
|
230
|
-
wasm.__wbg_tsne_free(ptr);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* @param {Array<any>} vectors
|
|
234
|
-
*/
|
|
235
|
-
constructor(vectors) {
|
|
236
|
-
const ret = wasm.tsne_new(addHeapObject(vectors));
|
|
237
|
-
return tSNE.__wrap(ret);
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Performs a parallel Barnes-Hut approximation of the t-SNE algorithm.
|
|
241
|
-
*
|
|
242
|
-
* # Arguments
|
|
243
|
-
*
|
|
244
|
-
* * `theta` - determines the accuracy of the approximation. Must be **strictly greater than
|
|
245
|
-
* 0.0**. Large values for θ increase the speed of the algorithm but decrease its accuracy.
|
|
246
|
-
* For small values of θ it is less probable that a cell in the space partitioning tree will
|
|
247
|
-
* be treated as a single point. For θ equal to 0.0 the method degenerates in the exact
|
|
248
|
-
* version.
|
|
249
|
-
*
|
|
250
|
-
* * `metric_f` - metric function.
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* **Do note that** `metric_f` **must be a metric distance**, i.e. it must
|
|
254
|
-
* satisfy the [triangle inequality](https://en.wikipedia.org/wiki/Triangle_inequality).
|
|
255
|
-
* @param {number} epochs
|
|
256
|
-
* @returns {Array<any>}
|
|
257
|
-
*/
|
|
258
|
-
barnes_hut(epochs) {
|
|
259
|
-
const ret = wasm.tsne_barnes_hut(this.__wbg_ptr, epochs);
|
|
260
|
-
return takeObject(ret);
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Sets a new learning rate.
|
|
264
|
-
*
|
|
265
|
-
* # Arguments
|
|
266
|
-
*
|
|
267
|
-
* `learning_rate` - new value for the learning rate.
|
|
268
|
-
* @param {number} learning_rate
|
|
269
|
-
*/
|
|
270
|
-
set learning_rate(learning_rate) {
|
|
271
|
-
wasm.tsne_set_learning_rate(this.__wbg_ptr, learning_rate);
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* @param {number} theta
|
|
275
|
-
*/
|
|
276
|
-
set theta(theta) {
|
|
277
|
-
wasm.tsne_set_theta(this.__wbg_ptr, theta);
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Sets a new momentum.
|
|
281
|
-
*
|
|
282
|
-
* # Arguments
|
|
283
|
-
*
|
|
284
|
-
* `momentum` - new value for the momentum.
|
|
285
|
-
* @param {number} momentum
|
|
286
|
-
*/
|
|
287
|
-
set momentum(momentum) {
|
|
288
|
-
wasm.tsne_set_momentum(this.__wbg_ptr, momentum);
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Sets a new final momentum.
|
|
292
|
-
*
|
|
293
|
-
* # Arguments
|
|
294
|
-
*
|
|
295
|
-
* `final_momentum` - new value for the final momentum.
|
|
296
|
-
* @param {number} final_momentum
|
|
297
|
-
*/
|
|
298
|
-
set final_momentum(final_momentum) {
|
|
299
|
-
wasm.tsne_set_final_momentum(this.__wbg_ptr, final_momentum);
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* Sets a new momentum switch epoch, i.e. the epoch after which the algorithm switches to
|
|
303
|
-
* `final_momentum` for the map update.
|
|
304
|
-
*
|
|
305
|
-
* # Arguments
|
|
306
|
-
*
|
|
307
|
-
* `momentum_switch_epoch` - new value for the momentum switch epoch.
|
|
308
|
-
* @param {number} momentum_switch_epoch
|
|
309
|
-
*/
|
|
310
|
-
set momentum_switch_epoch(momentum_switch_epoch) {
|
|
311
|
-
wasm.tsne_set_momentum_switch_epoch(this.__wbg_ptr, momentum_switch_epoch);
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Sets a new stop lying epoch, i.e. the epoch after which the P distribution values become
|
|
315
|
-
* true, as defined in the original implementation. For epochs < `stop_lying_epoch` the values
|
|
316
|
-
* of the P distribution are multiplied by a factor equal to `12.0`.
|
|
317
|
-
*
|
|
318
|
-
* # Arguments
|
|
319
|
-
*
|
|
320
|
-
* `stop_lying_epoch` - new value for the stop lying epoch.
|
|
321
|
-
* @param {number} stop_lying_epoch
|
|
322
|
-
*/
|
|
323
|
-
set stop_lying_epoch(stop_lying_epoch) {
|
|
324
|
-
wasm.tsne_set_stop_lying_epoch(this.__wbg_ptr, stop_lying_epoch);
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Sets a new value for the embedding dimension.
|
|
328
|
-
*
|
|
329
|
-
* # Arguments
|
|
330
|
-
*
|
|
331
|
-
* `embedding_dim` - new value for the embedding space dimensionality.
|
|
332
|
-
* @param {number} embedding_dim
|
|
333
|
-
*/
|
|
334
|
-
set embedding_dim(embedding_dim) {
|
|
335
|
-
wasm.tsne_set_embedding_dim(this.__wbg_ptr, embedding_dim);
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Sets a new perplexity value.
|
|
339
|
-
*
|
|
340
|
-
* # Arguments
|
|
341
|
-
*
|
|
342
|
-
* `perplexity` - new value for the perplexity. It's used so that the bandwidth of the Gaussian
|
|
343
|
-
* kernels, is set in such a way that the perplexity of each the conditional distribution *Pi*
|
|
344
|
-
* equals a predefined perplexity *u*.
|
|
345
|
-
*
|
|
346
|
-
* A good value for perplexity lies between 5.0 and 50.0.
|
|
347
|
-
* @param {number} perplexity
|
|
348
|
-
*/
|
|
349
|
-
set perplexity(perplexity) {
|
|
350
|
-
wasm.tsne_set_perplexity(this.__wbg_ptr, perplexity);
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Returns the computed embedding.
|
|
354
|
-
* @returns {Array<any>}
|
|
355
|
-
*/
|
|
356
|
-
embedding() {
|
|
357
|
-
const ret = wasm.tsne_embedding(this.__wbg_ptr);
|
|
358
|
-
return takeObject(ret);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
export function __wbindgen_object_drop_ref(arg0) {
|
|
363
|
-
takeObject(arg0);
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
export function __wbindgen_number_get(arg0, arg1) {
|
|
367
|
-
const obj = getObject(arg1);
|
|
368
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
369
|
-
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
|
370
|
-
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
export function __wbg_new_abda76e883ba8a5f() {
|
|
374
|
-
const ret = new Error();
|
|
375
|
-
return addHeapObject(ret);
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
export function __wbg_stack_658279fe44541cf6(arg0, arg1) {
|
|
379
|
-
const ret = getObject(arg1).stack;
|
|
380
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
381
|
-
const len1 = WASM_VECTOR_LEN;
|
|
382
|
-
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
383
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
export function __wbg_error_f851667af71bcfc6(arg0, arg1) {
|
|
387
|
-
let deferred0_0;
|
|
388
|
-
let deferred0_1;
|
|
389
|
-
try {
|
|
390
|
-
deferred0_0 = arg0;
|
|
391
|
-
deferred0_1 = arg1;
|
|
392
|
-
console.error(getStringFromWasm0(arg0, arg1));
|
|
393
|
-
} finally {
|
|
394
|
-
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
395
|
-
}
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
export function __wbg_randomFillSync_dc1e9a60c158336d() { return handleError(function (arg0, arg1) {
|
|
399
|
-
getObject(arg0).randomFillSync(takeObject(arg1));
|
|
400
|
-
}, arguments) };
|
|
401
|
-
|
|
402
|
-
export function __wbg_getRandomValues_37fa2ca9e4e07fab() { return handleError(function (arg0, arg1) {
|
|
403
|
-
getObject(arg0).getRandomValues(getObject(arg1));
|
|
404
|
-
}, arguments) };
|
|
405
|
-
|
|
406
|
-
export function __wbg_crypto_c48a774b022d20ac(arg0) {
|
|
407
|
-
const ret = getObject(arg0).crypto;
|
|
408
|
-
return addHeapObject(ret);
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
export function __wbindgen_is_object(arg0) {
|
|
412
|
-
const val = getObject(arg0);
|
|
413
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
414
|
-
return ret;
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
export function __wbg_process_298734cf255a885d(arg0) {
|
|
418
|
-
const ret = getObject(arg0).process;
|
|
419
|
-
return addHeapObject(ret);
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
export function __wbg_versions_e2e78e134e3e5d01(arg0) {
|
|
423
|
-
const ret = getObject(arg0).versions;
|
|
424
|
-
return addHeapObject(ret);
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
export function __wbg_node_1cd7a5d853dbea79(arg0) {
|
|
428
|
-
const ret = getObject(arg0).node;
|
|
429
|
-
return addHeapObject(ret);
|
|
430
|
-
};
|
|
431
|
-
|
|
432
|
-
export function __wbindgen_is_string(arg0) {
|
|
433
|
-
const ret = typeof(getObject(arg0)) === 'string';
|
|
434
|
-
return ret;
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
export function __wbg_require_8f08ceecec0f4fee() { return handleError(function () {
|
|
438
|
-
const ret = module.require;
|
|
439
|
-
return addHeapObject(ret);
|
|
440
|
-
}, arguments) };
|
|
441
|
-
|
|
442
|
-
export function __wbindgen_string_new(arg0, arg1) {
|
|
443
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
444
|
-
return addHeapObject(ret);
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
export function __wbg_msCrypto_bcb970640f50a1e8(arg0) {
|
|
448
|
-
const ret = getObject(arg0).msCrypto;
|
|
449
|
-
return addHeapObject(ret);
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
export function __wbg_get_44be0491f933a435(arg0, arg1) {
|
|
453
|
-
const ret = getObject(arg0)[arg1 >>> 0];
|
|
454
|
-
return addHeapObject(ret);
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
export function __wbg_length_fff51ee6522a1a18(arg0) {
|
|
458
|
-
const ret = getObject(arg0).length;
|
|
459
|
-
return ret;
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
export function __wbg_new_898a68150f225f2e() {
|
|
463
|
-
const ret = new Array();
|
|
464
|
-
return addHeapObject(ret);
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
export function __wbindgen_is_function(arg0) {
|
|
468
|
-
const ret = typeof(getObject(arg0)) === 'function';
|
|
469
|
-
return ret;
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
export function __wbg_newnoargs_581967eacc0e2604(arg0, arg1) {
|
|
473
|
-
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
474
|
-
return addHeapObject(ret);
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
export function __wbg_call_cb65541d95d71282() { return handleError(function (arg0, arg1) {
|
|
478
|
-
const ret = getObject(arg0).call(getObject(arg1));
|
|
479
|
-
return addHeapObject(ret);
|
|
480
|
-
}, arguments) };
|
|
481
|
-
|
|
482
|
-
export function __wbg_self_1ff1d729e9aae938() { return handleError(function () {
|
|
483
|
-
const ret = self.self;
|
|
484
|
-
return addHeapObject(ret);
|
|
485
|
-
}, arguments) };
|
|
486
|
-
|
|
487
|
-
export function __wbg_window_5f4faef6c12b79ec() { return handleError(function () {
|
|
488
|
-
const ret = window.window;
|
|
489
|
-
return addHeapObject(ret);
|
|
490
|
-
}, arguments) };
|
|
491
|
-
|
|
492
|
-
export function __wbg_globalThis_1d39714405582d3c() { return handleError(function () {
|
|
493
|
-
const ret = globalThis.globalThis;
|
|
494
|
-
return addHeapObject(ret);
|
|
495
|
-
}, arguments) };
|
|
496
|
-
|
|
497
|
-
export function __wbg_global_651f05c6a0944d1c() { return handleError(function () {
|
|
498
|
-
const ret = global.global;
|
|
499
|
-
return addHeapObject(ret);
|
|
500
|
-
}, arguments) };
|
|
501
|
-
|
|
502
|
-
export function __wbindgen_is_undefined(arg0) {
|
|
503
|
-
const ret = getObject(arg0) === undefined;
|
|
504
|
-
return ret;
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
export function __wbg_isArray_4c24b343cb13cfb1(arg0) {
|
|
508
|
-
const ret = Array.isArray(getObject(arg0));
|
|
509
|
-
return ret;
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
export function __wbg_push_ca1c26067ef907ac(arg0, arg1) {
|
|
513
|
-
const ret = getObject(arg0).push(getObject(arg1));
|
|
514
|
-
return ret;
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
export function __wbg_call_01734de55d61e11d() { return handleError(function (arg0, arg1, arg2) {
|
|
518
|
-
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
519
|
-
return addHeapObject(ret);
|
|
520
|
-
}, arguments) };
|
|
521
|
-
|
|
522
|
-
export function __wbg_buffer_085ec1f694018c4f(arg0) {
|
|
523
|
-
const ret = getObject(arg0).buffer;
|
|
524
|
-
return addHeapObject(ret);
|
|
525
|
-
};
|
|
526
|
-
|
|
527
|
-
export function __wbg_newwithbyteoffsetandlength_6da8e527659b86aa(arg0, arg1, arg2) {
|
|
528
|
-
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
529
|
-
return addHeapObject(ret);
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
export function __wbg_new_8125e318e6245eed(arg0) {
|
|
533
|
-
const ret = new Uint8Array(getObject(arg0));
|
|
534
|
-
return addHeapObject(ret);
|
|
535
|
-
};
|
|
536
|
-
|
|
537
|
-
export function __wbg_set_5cf90238115182c3(arg0, arg1, arg2) {
|
|
538
|
-
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
export function __wbg_newwithbyteoffsetandlength_69193e31c844b792(arg0, arg1, arg2) {
|
|
542
|
-
const ret = new Float32Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
543
|
-
return addHeapObject(ret);
|
|
544
|
-
};
|
|
545
|
-
|
|
546
|
-
export function __wbg_new_d086a66d1c264b3f(arg0) {
|
|
547
|
-
const ret = new Float32Array(getObject(arg0));
|
|
548
|
-
return addHeapObject(ret);
|
|
549
|
-
};
|
|
550
|
-
|
|
551
|
-
export function __wbg_newwithlength_e5d69174d6984cd7(arg0) {
|
|
552
|
-
const ret = new Uint8Array(arg0 >>> 0);
|
|
553
|
-
return addHeapObject(ret);
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
export function __wbg_subarray_13db269f57aa838d(arg0, arg1, arg2) {
|
|
557
|
-
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
558
|
-
return addHeapObject(ret);
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
export function __wbindgen_object_clone_ref(arg0) {
|
|
562
|
-
const ret = getObject(arg0);
|
|
563
|
-
return addHeapObject(ret);
|
|
564
|
-
};
|
|
565
|
-
|
|
566
|
-
export function __wbindgen_debug_string(arg0, arg1) {
|
|
567
|
-
const ret = debugString(getObject(arg1));
|
|
568
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
569
|
-
const len1 = WASM_VECTOR_LEN;
|
|
570
|
-
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
571
|
-
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
572
|
-
};
|
|
573
|
-
|
|
574
|
-
export function __wbindgen_throw(arg0, arg1) {
|
|
575
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
576
|
-
};
|
|
577
|
-
|
|
578
|
-
export function __wbindgen_memory() {
|
|
579
|
-
const ret = wasm.memory;
|
|
580
|
-
return addHeapObject(ret);
|
|
581
|
-
};
|
|
582
|
-
|