wasm-bhtsne 1.0.0 → 1.1.0
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/LICENSE +0 -0
- package/README.md +41 -5
- package/package.json +1 -1
- package/wasm_bhtsne.d.ts +21 -98
- package/wasm_bhtsne.js +122 -134
- package/wasm_bhtsne_bg.wasm +0 -0
package/LICENSE
CHANGED
|
File without changes
|
package/README.md
CHANGED
|
@@ -10,8 +10,17 @@ This is the wasm version of the [bhtsne](https://github.com/frjnn/bhtsne) crate.
|
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
- Harnesses multi-threading capabilities through [wasm-bindgen-rayon](https://github.com/RReverser/wasm-bindgen-rayon).
|
|
13
|
+
- Allows passing t-SNE hyperparameters through a JavaScript object, where you only need to include the parameters you want to change from the defaults. If you don't specify any, default values are used.
|
|
14
|
+
- Supports running the algorithm in iterations, enabling progressive refinement of the embedding
|
|
15
|
+
- Supports both Float32Array and Float64Array for data input
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
To use the multithreading feature, you need to enable `SharedArrayBuffer` on the Web. As stated in the [wasm-bindgen-rayon readme](https://github.com/RReverser/wasm-bindgen-rayon/blob/main/README.md):
|
|
19
|
+
|
|
20
|
+
In order to use `SharedArrayBuffer` on the Web, you need to enable [cross-origin isolation policies](https://web.dev/coop-coep/). Check out the linked article for details.
|
|
13
21
|
|
|
14
22
|
## Installation
|
|
23
|
+
Install the [wasm-bhtsne npm package](https://www.npmjs.com/package/wasm-bhtsne):
|
|
15
24
|
```shell
|
|
16
25
|
npm i wasm-bhtsne
|
|
17
26
|
```
|
|
@@ -41,16 +50,43 @@ function createRandomMatrix(rows, columns) {
|
|
|
41
50
|
async onclick() {
|
|
42
51
|
|
|
43
52
|
// create random points and dimensions
|
|
44
|
-
const data = createRandomMatrix(
|
|
53
|
+
const data = createRandomMatrix(5000, 512);
|
|
54
|
+
|
|
55
|
+
// Example of setting hyperparameters
|
|
56
|
+
const opt = {
|
|
57
|
+
learning_rate: 150.0,
|
|
58
|
+
perplexity: 30.0,
|
|
59
|
+
theta: 0.6
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// let tsne_encoder = new multiThread.bhtSNEf64(data, opt);
|
|
63
|
+
// or
|
|
64
|
+
let tsne_encoder = new multiThread.bhtSNEf32(data, opt);
|
|
65
|
+
let compressed_vectors;
|
|
45
66
|
|
|
46
|
-
let
|
|
47
|
-
|
|
67
|
+
for (let i = 0; i < 1000; i++) {
|
|
68
|
+
compressed_vectors = tsne_encoder.step(1)
|
|
69
|
+
/* …do something with `compressed_vectors`… */
|
|
70
|
+
}
|
|
48
71
|
|
|
49
|
-
// run the algorithm with 1000 iterations
|
|
50
|
-
let compressed_vectors = tsne_encoder.step(1000);
|
|
51
72
|
console.log("Compressed Vectors:", compressed_vectors);
|
|
52
73
|
},
|
|
53
74
|
disabled: false
|
|
54
75
|
});
|
|
55
76
|
})();
|
|
56
77
|
```
|
|
78
|
+
|
|
79
|
+
## Hyperparameters
|
|
80
|
+
Here is a list of hyperparameters that can be set in the JavaScript object, along with their default values and descriptions:
|
|
81
|
+
|
|
82
|
+
- **`learning_rate`** (default: `200.0`): controls the step size during the optimization.
|
|
83
|
+
- **`momentum`** (default: `0.5`): helps accelerate gradients vectors in the right directions, thus leading to faster converging.
|
|
84
|
+
- **`final_momentum`** (default: `0.8`): momentum value used after a certain number of iterations.
|
|
85
|
+
- **`momentum_switch_epoch`** (default: `250`): the epoch after which the algorithm switches to `final_momentum` for the map update.
|
|
86
|
+
- **`stop_lying_epoch`** (default: `250`): the epoch after which the P distribution values become true. For epochs < `stop_lying_epoch`, the values of the P distribution are multiplied by a factor equal to `12.0`.
|
|
87
|
+
- **`theta`** (default: `0.5`): Determines the accuracy of the approximation. Larger values increase the speed but decrease accuracy. Must be strictly greater than 0.0.
|
|
88
|
+
- **`embedding_dim`** (default: `2`): the dimensionality of the embedding space.
|
|
89
|
+
- **`perplexity`** (default: `20.0`): the perplexity value. It determines the balance between local and global aspects of the data. A good value lies between 5.0 and 50.0.
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
package/package.json
CHANGED
package/wasm_bhtsne.d.ts
CHANGED
|
@@ -13,114 +13,43 @@ export function wbg_rayon_start_worker(receiver: number): void;
|
|
|
13
13
|
* t-distributed stochastic neighbor embedding. Provides a parallel implementation of both the
|
|
14
14
|
* exact version of the algorithm and the tree accelerated one leveraging space partitioning trees.
|
|
15
15
|
*/
|
|
16
|
-
export class
|
|
16
|
+
export class bhtSNEf32 {
|
|
17
17
|
free(): void;
|
|
18
18
|
/**
|
|
19
19
|
* @param {any} data
|
|
20
|
+
* @param {any} opt
|
|
20
21
|
*/
|
|
21
|
-
constructor(data: any);
|
|
22
|
+
constructor(data: any, opt: any);
|
|
22
23
|
/**
|
|
23
24
|
* Performs a parallel Barnes-Hut approximation of the t-SNE algorithm.
|
|
24
25
|
*
|
|
25
26
|
* # Arguments
|
|
26
27
|
*
|
|
27
|
-
* `epochs` -
|
|
28
|
+
* `epochs` - the maximum number of fitting iterations. Must be positive
|
|
28
29
|
* @param {number} epochs
|
|
29
30
|
* @returns {any}
|
|
30
31
|
*/
|
|
31
32
|
step(epochs: number): any;
|
|
33
|
+
}
|
|
32
34
|
/**
|
|
33
|
-
* Sets a new learning rate.
|
|
34
|
-
*
|
|
35
|
-
* # Arguments
|
|
36
|
-
*
|
|
37
|
-
* `learning_rate` - new value for the learning rate.
|
|
38
|
-
* @param {number} learning_rate
|
|
39
|
-
*/
|
|
40
|
-
learning_rate(learning_rate: number): void;
|
|
41
|
-
/**
|
|
42
|
-
* Sets new epochs, i.e the maximum number of fitting iterations.
|
|
43
|
-
*
|
|
44
|
-
* # Arguments
|
|
45
|
-
*
|
|
46
|
-
* `epochs` - new value for the epochs.
|
|
47
|
-
* @param {number} epochs
|
|
48
|
-
*/
|
|
49
|
-
epochs(epochs: number): void;
|
|
50
|
-
/**
|
|
51
|
-
* Sets a new momentum.
|
|
52
|
-
*
|
|
53
|
-
* # Arguments
|
|
54
|
-
*
|
|
55
|
-
* `momentum` - new value for the momentum.
|
|
56
|
-
* @param {number} momentum
|
|
57
|
-
*/
|
|
58
|
-
momentum(momentum: number): void;
|
|
59
|
-
/**
|
|
60
|
-
* Sets a new final momentum.
|
|
61
|
-
*
|
|
62
|
-
* # Arguments
|
|
63
|
-
*
|
|
64
|
-
* `final_momentum` - new value for the final momentum.
|
|
65
|
-
* @param {number} final_momentum
|
|
66
|
-
*/
|
|
67
|
-
final_momentum(final_momentum: number): void;
|
|
68
|
-
/**
|
|
69
|
-
* Sets a new momentum switch epoch, i.e. the epoch after which the algorithm switches to
|
|
70
|
-
* `final_momentum` for the map update.
|
|
71
|
-
*
|
|
72
|
-
* # Arguments
|
|
73
|
-
*
|
|
74
|
-
* `momentum_switch_epoch` - new value for the momentum switch epoch.
|
|
75
|
-
* @param {number} momentum_switch_epoch
|
|
76
|
-
*/
|
|
77
|
-
momentum_switch_epoch(momentum_switch_epoch: number): void;
|
|
78
|
-
/**
|
|
79
|
-
* Sets a new stop lying epoch, i.e. the epoch after which the P distribution values become
|
|
80
|
-
* true, as defined in the original implementation. For epochs < `stop_lying_epoch` the values
|
|
81
|
-
* of the P distribution are multiplied by a factor equal to `12.0`.
|
|
82
|
-
*
|
|
83
|
-
* # Arguments
|
|
84
|
-
*
|
|
85
|
-
* `stop_lying_epoch` - new value for the stop lying epoch.
|
|
86
|
-
* @param {number} stop_lying_epoch
|
|
87
|
-
*/
|
|
88
|
-
stop_lying_epoch(stop_lying_epoch: number): void;
|
|
89
|
-
/**
|
|
90
|
-
* Sets a new theta, which determines the accuracy of the approximation. Must be **strictly greater than
|
|
91
|
-
* 0.0**. Large values for θ increase the speed of the algorithm but decrease its accuracy.
|
|
92
|
-
* For small values of θ it is less probable that a cell in the space partitioning tree will
|
|
93
|
-
* be treated as a single point. For θ equal to 0.0 the method degenerates in the exact
|
|
94
|
-
* version.
|
|
95
|
-
*
|
|
96
|
-
* # Arguments
|
|
97
|
-
*
|
|
98
|
-
* * `theta` - new value for the theta.
|
|
99
|
-
* @param {number} theta
|
|
100
35
|
*/
|
|
101
|
-
|
|
36
|
+
export class bhtSNEf64 {
|
|
37
|
+
free(): void;
|
|
102
38
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* # Arguments
|
|
106
|
-
*
|
|
107
|
-
* `embedding_dim` - new value for the embedding space dimensionality.
|
|
108
|
-
* @param {number} embedding_dim
|
|
39
|
+
* @param {any} data
|
|
40
|
+
* @param {any} opt
|
|
109
41
|
*/
|
|
110
|
-
|
|
42
|
+
constructor(data: any, opt: any);
|
|
111
43
|
/**
|
|
112
|
-
*
|
|
44
|
+
* Performs a parallel Barnes-Hut approximation of the t-SNE algorithm.
|
|
113
45
|
*
|
|
114
46
|
* # Arguments
|
|
115
47
|
*
|
|
116
|
-
* `
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* A good value for perplexity lies between 5.0 and 50.0.
|
|
121
|
-
* @param {number} perplexity
|
|
48
|
+
* `epochs` - Sets epochs, the maximum number of fitting iterations.
|
|
49
|
+
* @param {number} epochs
|
|
50
|
+
* @returns {any}
|
|
122
51
|
*/
|
|
123
|
-
|
|
52
|
+
step(epochs: number): any;
|
|
124
53
|
}
|
|
125
54
|
/**
|
|
126
55
|
*/
|
|
@@ -142,18 +71,12 @@ export class wbg_rayon_PoolBuilder {
|
|
|
142
71
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
143
72
|
|
|
144
73
|
export interface InitOutput {
|
|
145
|
-
readonly
|
|
146
|
-
readonly
|
|
147
|
-
readonly
|
|
148
|
-
readonly
|
|
149
|
-
readonly
|
|
150
|
-
readonly
|
|
151
|
-
readonly bhtsne_final_momentum: (a: number, b: number) => void;
|
|
152
|
-
readonly bhtsne_momentum_switch_epoch: (a: number, b: number) => void;
|
|
153
|
-
readonly bhtsne_stop_lying_epoch: (a: number, b: number) => void;
|
|
154
|
-
readonly bhtsne_theta: (a: number, b: number) => void;
|
|
155
|
-
readonly bhtsne_embedding_dim: (a: number, b: number) => void;
|
|
156
|
-
readonly bhtsne_perplexity: (a: number, b: number) => void;
|
|
74
|
+
readonly __wbg_bhtsnef32_free: (a: number) => void;
|
|
75
|
+
readonly bhtsnef32_new: (a: number, b: number) => number;
|
|
76
|
+
readonly bhtsnef32_step: (a: number, b: number, c: number) => void;
|
|
77
|
+
readonly __wbg_bhtsnef64_free: (a: number) => void;
|
|
78
|
+
readonly bhtsnef64_new: (a: number, b: number) => number;
|
|
79
|
+
readonly bhtsnef64_step: (a: number, b: number, c: number) => void;
|
|
157
80
|
readonly __wbg_wbg_rayon_poolbuilder_free: (a: number) => void;
|
|
158
81
|
readonly wbg_rayon_poolbuilder_numThreads: (a: number) => number;
|
|
159
82
|
readonly wbg_rayon_poolbuilder_receiver: (a: number) => number;
|
package/wasm_bhtsne.js
CHANGED
|
@@ -53,7 +53,9 @@ function addHeapObject(obj) {
|
|
|
53
53
|
return idx;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
57
|
+
|
|
58
|
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
57
59
|
|
|
58
60
|
let cachedUint8Memory0 = null;
|
|
59
61
|
|
|
@@ -64,6 +66,13 @@ function getUint8Memory0() {
|
|
|
64
66
|
return cachedUint8Memory0;
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
function getStringFromWasm0(ptr, len) {
|
|
70
|
+
ptr = ptr >>> 0;
|
|
71
|
+
return cachedTextDecoder.decode(getUint8Memory0().slice(ptr, ptr + len));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
let WASM_VECTOR_LEN = 0;
|
|
75
|
+
|
|
67
76
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
68
77
|
|
|
69
78
|
const encodeString = function (arg, view) {
|
|
@@ -114,13 +123,13 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
114
123
|
return ptr;
|
|
115
124
|
}
|
|
116
125
|
|
|
117
|
-
|
|
126
|
+
let cachedBigInt64Memory0 = null;
|
|
118
127
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return
|
|
128
|
+
function getBigInt64Memory0() {
|
|
129
|
+
if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.buffer !== wasm.memory.buffer) {
|
|
130
|
+
cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
|
|
131
|
+
}
|
|
132
|
+
return cachedBigInt64Memory0;
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
function debugString(val) {
|
|
@@ -211,31 +220,32 @@ export function wbg_rayon_start_worker(receiver) {
|
|
|
211
220
|
wasm.wbg_rayon_start_worker(receiver);
|
|
212
221
|
}
|
|
213
222
|
|
|
214
|
-
const
|
|
223
|
+
const bhtSNEf32Finalization = (typeof FinalizationRegistry === 'undefined')
|
|
215
224
|
? { register: () => {}, unregister: () => {} }
|
|
216
|
-
: new FinalizationRegistry(ptr => wasm.
|
|
225
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_bhtsnef32_free(ptr >>> 0));
|
|
217
226
|
/**
|
|
218
227
|
* t-distributed stochastic neighbor embedding. Provides a parallel implementation of both the
|
|
219
228
|
* exact version of the algorithm and the tree accelerated one leveraging space partitioning trees.
|
|
220
229
|
*/
|
|
221
|
-
export class
|
|
230
|
+
export class bhtSNEf32 {
|
|
222
231
|
|
|
223
232
|
__destroy_into_raw() {
|
|
224
233
|
const ptr = this.__wbg_ptr;
|
|
225
234
|
this.__wbg_ptr = 0;
|
|
226
|
-
|
|
235
|
+
bhtSNEf32Finalization.unregister(this);
|
|
227
236
|
return ptr;
|
|
228
237
|
}
|
|
229
238
|
|
|
230
239
|
free() {
|
|
231
240
|
const ptr = this.__destroy_into_raw();
|
|
232
|
-
wasm.
|
|
241
|
+
wasm.__wbg_bhtsnef32_free(ptr);
|
|
233
242
|
}
|
|
234
243
|
/**
|
|
235
244
|
* @param {any} data
|
|
245
|
+
* @param {any} opt
|
|
236
246
|
*/
|
|
237
|
-
constructor(data) {
|
|
238
|
-
const ret = wasm.
|
|
247
|
+
constructor(data, opt) {
|
|
248
|
+
const ret = wasm.bhtsnef32_new(addHeapObject(data), addHeapObject(opt));
|
|
239
249
|
this.__wbg_ptr = ret >>> 0;
|
|
240
250
|
return this;
|
|
241
251
|
}
|
|
@@ -244,14 +254,14 @@ export class bhtSNE {
|
|
|
244
254
|
*
|
|
245
255
|
* # Arguments
|
|
246
256
|
*
|
|
247
|
-
* `epochs` -
|
|
257
|
+
* `epochs` - the maximum number of fitting iterations. Must be positive
|
|
248
258
|
* @param {number} epochs
|
|
249
259
|
* @returns {any}
|
|
250
260
|
*/
|
|
251
261
|
step(epochs) {
|
|
252
262
|
try {
|
|
253
263
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
254
|
-
wasm.
|
|
264
|
+
wasm.bhtsnef32_step(retptr, this.__wbg_ptr, epochs);
|
|
255
265
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
256
266
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
257
267
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
@@ -263,115 +273,58 @@ export class bhtSNE {
|
|
|
263
273
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
264
274
|
}
|
|
265
275
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
* # Arguments
|
|
281
|
-
*
|
|
282
|
-
* `epochs` - new value for the epochs.
|
|
283
|
-
* @param {number} epochs
|
|
284
|
-
*/
|
|
285
|
-
epochs(epochs) {
|
|
286
|
-
wasm.bhtsne_epochs(this.__wbg_ptr, epochs);
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Sets a new momentum.
|
|
290
|
-
*
|
|
291
|
-
* # Arguments
|
|
292
|
-
*
|
|
293
|
-
* `momentum` - new value for the momentum.
|
|
294
|
-
* @param {number} momentum
|
|
295
|
-
*/
|
|
296
|
-
momentum(momentum) {
|
|
297
|
-
wasm.bhtsne_momentum(this.__wbg_ptr, momentum);
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Sets a new final momentum.
|
|
301
|
-
*
|
|
302
|
-
* # Arguments
|
|
303
|
-
*
|
|
304
|
-
* `final_momentum` - new value for the final momentum.
|
|
305
|
-
* @param {number} final_momentum
|
|
306
|
-
*/
|
|
307
|
-
final_momentum(final_momentum) {
|
|
308
|
-
wasm.bhtsne_final_momentum(this.__wbg_ptr, final_momentum);
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Sets a new momentum switch epoch, i.e. the epoch after which the algorithm switches to
|
|
312
|
-
* `final_momentum` for the map update.
|
|
313
|
-
*
|
|
314
|
-
* # Arguments
|
|
315
|
-
*
|
|
316
|
-
* `momentum_switch_epoch` - new value for the momentum switch epoch.
|
|
317
|
-
* @param {number} momentum_switch_epoch
|
|
318
|
-
*/
|
|
319
|
-
momentum_switch_epoch(momentum_switch_epoch) {
|
|
320
|
-
wasm.bhtsne_momentum_switch_epoch(this.__wbg_ptr, momentum_switch_epoch);
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Sets a new stop lying epoch, i.e. the epoch after which the P distribution values become
|
|
324
|
-
* true, as defined in the original implementation. For epochs < `stop_lying_epoch` the values
|
|
325
|
-
* of the P distribution are multiplied by a factor equal to `12.0`.
|
|
326
|
-
*
|
|
327
|
-
* # Arguments
|
|
328
|
-
*
|
|
329
|
-
* `stop_lying_epoch` - new value for the stop lying epoch.
|
|
330
|
-
* @param {number} stop_lying_epoch
|
|
331
|
-
*/
|
|
332
|
-
stop_lying_epoch(stop_lying_epoch) {
|
|
333
|
-
wasm.bhtsne_stop_lying_epoch(this.__wbg_ptr, stop_lying_epoch);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const bhtSNEf64Finalization = (typeof FinalizationRegistry === 'undefined')
|
|
279
|
+
? { register: () => {}, unregister: () => {} }
|
|
280
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_bhtsnef64_free(ptr >>> 0));
|
|
281
|
+
/**
|
|
282
|
+
*/
|
|
283
|
+
export class bhtSNEf64 {
|
|
284
|
+
|
|
285
|
+
__destroy_into_raw() {
|
|
286
|
+
const ptr = this.__wbg_ptr;
|
|
287
|
+
this.__wbg_ptr = 0;
|
|
288
|
+
bhtSNEf64Finalization.unregister(this);
|
|
289
|
+
return ptr;
|
|
334
290
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
* be treated as a single point. For θ equal to 0.0 the method degenerates in the exact
|
|
340
|
-
* version.
|
|
341
|
-
*
|
|
342
|
-
* # Arguments
|
|
343
|
-
*
|
|
344
|
-
* * `theta` - new value for the theta.
|
|
345
|
-
* @param {number} theta
|
|
346
|
-
*/
|
|
347
|
-
theta(theta) {
|
|
348
|
-
wasm.bhtsne_theta(this.__wbg_ptr, theta);
|
|
291
|
+
|
|
292
|
+
free() {
|
|
293
|
+
const ptr = this.__destroy_into_raw();
|
|
294
|
+
wasm.__wbg_bhtsnef64_free(ptr);
|
|
349
295
|
}
|
|
350
296
|
/**
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
* # Arguments
|
|
354
|
-
*
|
|
355
|
-
* `embedding_dim` - new value for the embedding space dimensionality.
|
|
356
|
-
* @param {number} embedding_dim
|
|
297
|
+
* @param {any} data
|
|
298
|
+
* @param {any} opt
|
|
357
299
|
*/
|
|
358
|
-
|
|
359
|
-
wasm.
|
|
300
|
+
constructor(data, opt) {
|
|
301
|
+
const ret = wasm.bhtsnef64_new(addHeapObject(data), addHeapObject(opt));
|
|
302
|
+
this.__wbg_ptr = ret >>> 0;
|
|
303
|
+
return this;
|
|
360
304
|
}
|
|
361
305
|
/**
|
|
362
|
-
*
|
|
306
|
+
* Performs a parallel Barnes-Hut approximation of the t-SNE algorithm.
|
|
363
307
|
*
|
|
364
308
|
* # Arguments
|
|
365
309
|
*
|
|
366
|
-
* `
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
* A good value for perplexity lies between 5.0 and 50.0.
|
|
371
|
-
* @param {number} perplexity
|
|
310
|
+
* `epochs` - Sets epochs, the maximum number of fitting iterations.
|
|
311
|
+
* @param {number} epochs
|
|
312
|
+
* @returns {any}
|
|
372
313
|
*/
|
|
373
|
-
|
|
374
|
-
|
|
314
|
+
step(epochs) {
|
|
315
|
+
try {
|
|
316
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
317
|
+
wasm.bhtsnef64_step(retptr, this.__wbg_ptr, epochs);
|
|
318
|
+
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
319
|
+
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
320
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
321
|
+
if (r2) {
|
|
322
|
+
throw takeObject(r1);
|
|
323
|
+
}
|
|
324
|
+
return takeObject(r0);
|
|
325
|
+
} finally {
|
|
326
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
327
|
+
}
|
|
375
328
|
}
|
|
376
329
|
}
|
|
377
330
|
|
|
@@ -459,21 +412,45 @@ function __wbg_get_imports() {
|
|
|
459
412
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
460
413
|
takeObject(arg0);
|
|
461
414
|
};
|
|
415
|
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
416
|
+
const ret = getObject(arg0) === undefined;
|
|
417
|
+
return ret;
|
|
418
|
+
};
|
|
419
|
+
imports.wbg.__wbindgen_in = function(arg0, arg1) {
|
|
420
|
+
const ret = getObject(arg0) in getObject(arg1);
|
|
421
|
+
return ret;
|
|
422
|
+
};
|
|
462
423
|
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
|
463
424
|
const obj = getObject(arg1);
|
|
464
425
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
465
426
|
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
|
|
466
427
|
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
467
428
|
};
|
|
468
|
-
imports.wbg.
|
|
469
|
-
const ret = getObject(arg0);
|
|
429
|
+
imports.wbg.__wbindgen_is_bigint = function(arg0) {
|
|
430
|
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
|
431
|
+
return ret;
|
|
432
|
+
};
|
|
433
|
+
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
|
|
434
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
470
435
|
return addHeapObject(ret);
|
|
471
436
|
};
|
|
437
|
+
imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
|
|
438
|
+
const ret = getObject(arg0) === getObject(arg1);
|
|
439
|
+
return ret;
|
|
440
|
+
};
|
|
472
441
|
imports.wbg.__wbindgen_is_object = function(arg0) {
|
|
473
442
|
const val = getObject(arg0);
|
|
474
443
|
const ret = typeof(val) === 'object' && val !== null;
|
|
475
444
|
return ret;
|
|
476
445
|
};
|
|
446
|
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
|
447
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
448
|
+
return addHeapObject(ret);
|
|
449
|
+
};
|
|
450
|
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
451
|
+
const ret = getObject(arg0);
|
|
452
|
+
return addHeapObject(ret);
|
|
453
|
+
};
|
|
477
454
|
imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
|
|
478
455
|
const ret = getObject(arg0) == getObject(arg1);
|
|
479
456
|
return ret;
|
|
@@ -491,9 +468,9 @@ function __wbg_get_imports() {
|
|
|
491
468
|
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
492
469
|
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
493
470
|
};
|
|
494
|
-
imports.wbg.
|
|
495
|
-
const ret =
|
|
496
|
-
return
|
|
471
|
+
imports.wbg.__wbindgen_as_number = function(arg0) {
|
|
472
|
+
const ret = +getObject(arg0);
|
|
473
|
+
return ret;
|
|
497
474
|
};
|
|
498
475
|
imports.wbg.__wbindgen_number_new = function(arg0) {
|
|
499
476
|
const ret = arg0;
|
|
@@ -503,6 +480,20 @@ function __wbg_get_imports() {
|
|
|
503
480
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
504
481
|
return addHeapObject(ret);
|
|
505
482
|
};
|
|
483
|
+
imports.wbg.__wbg_getwithrefkey_edc2c8960f0f1191 = function(arg0, arg1) {
|
|
484
|
+
const ret = getObject(arg0)[getObject(arg1)];
|
|
485
|
+
return addHeapObject(ret);
|
|
486
|
+
};
|
|
487
|
+
imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) {
|
|
488
|
+
let result;
|
|
489
|
+
try {
|
|
490
|
+
result = getObject(arg0) instanceof Window;
|
|
491
|
+
} catch (_) {
|
|
492
|
+
result = false;
|
|
493
|
+
}
|
|
494
|
+
const ret = result;
|
|
495
|
+
return ret;
|
|
496
|
+
};
|
|
506
497
|
imports.wbg.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
|
|
507
498
|
const ret = getObject(arg0).crypto;
|
|
508
499
|
return addHeapObject(ret);
|
|
@@ -537,16 +528,6 @@ function __wbg_get_imports() {
|
|
|
537
528
|
imports.wbg.__wbg_getRandomValues_3aa56aa6edec874c = function() { return handleError(function (arg0, arg1) {
|
|
538
529
|
getObject(arg0).getRandomValues(getObject(arg1));
|
|
539
530
|
}, arguments) };
|
|
540
|
-
imports.wbg.__wbg_instanceof_Window_f401953a2cf86220 = function(arg0) {
|
|
541
|
-
let result;
|
|
542
|
-
try {
|
|
543
|
-
result = getObject(arg0) instanceof Window;
|
|
544
|
-
} catch (_) {
|
|
545
|
-
result = false;
|
|
546
|
-
}
|
|
547
|
-
const ret = result;
|
|
548
|
-
return ret;
|
|
549
|
-
};
|
|
550
531
|
imports.wbg.__wbg_get_bd8e338fbd5f5cc8 = function(arg0, arg1) {
|
|
551
532
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
552
533
|
return addHeapObject(ret);
|
|
@@ -611,10 +592,6 @@ function __wbg_get_imports() {
|
|
|
611
592
|
const ret = global.global;
|
|
612
593
|
return addHeapObject(ret);
|
|
613
594
|
}, arguments) };
|
|
614
|
-
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
|
615
|
-
const ret = getObject(arg0) === undefined;
|
|
616
|
-
return ret;
|
|
617
|
-
};
|
|
618
595
|
imports.wbg.__wbg_set_d4638f722068f043 = function(arg0, arg1, arg2) {
|
|
619
596
|
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
620
597
|
};
|
|
@@ -636,6 +613,10 @@ function __wbg_get_imports() {
|
|
|
636
613
|
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
637
614
|
return addHeapObject(ret);
|
|
638
615
|
}, arguments) };
|
|
616
|
+
imports.wbg.__wbg_isSafeInteger_f7b04ef02296c4d2 = function(arg0) {
|
|
617
|
+
const ret = Number.isSafeInteger(getObject(arg0));
|
|
618
|
+
return ret;
|
|
619
|
+
};
|
|
639
620
|
imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
|
|
640
621
|
const ret = getObject(arg0).buffer;
|
|
641
622
|
return addHeapObject(ret);
|
|
@@ -673,6 +654,12 @@ function __wbg_get_imports() {
|
|
|
673
654
|
const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
|
|
674
655
|
return addHeapObject(ret);
|
|
675
656
|
};
|
|
657
|
+
imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
|
|
658
|
+
const v = getObject(arg1);
|
|
659
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
660
|
+
getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret;
|
|
661
|
+
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
|
|
662
|
+
};
|
|
676
663
|
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
|
677
664
|
const ret = debugString(getObject(arg1));
|
|
678
665
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -706,6 +693,7 @@ function __wbg_init_memory(imports, maybe_memory) {
|
|
|
706
693
|
function __wbg_finalize_init(instance, module) {
|
|
707
694
|
wasm = instance.exports;
|
|
708
695
|
__wbg_init.__wbindgen_wasm_module = module;
|
|
696
|
+
cachedBigInt64Memory0 = null;
|
|
709
697
|
cachedFloat64Memory0 = null;
|
|
710
698
|
cachedInt32Memory0 = null;
|
|
711
699
|
cachedUint8Memory0 = null;
|
package/wasm_bhtsne_bg.wasm
CHANGED
|
Binary file
|