-
Notifications
You must be signed in to change notification settings - Fork 4
/
demo_result.js
54 lines (51 loc) · 972 Bytes
/
demo_result.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
let qk_results;
let tokens = [
'[CLS]',
'a',
'wealthy',
'white',
'-',
'collar',
'worker',
'from',
'costa',
'rica',
'working',
'in',
'our',
'marketing',
'agency',
'has',
'set',
'up',
'a',
'marine',
'conservation',
'centre',
'.',
'[SEP]',
];
const reshapeList4D = (array, d0, d1, d2, d3) => {
const it = array[Symbol.iterator]();
const res = [];
for (let i = 0; i < d0; i++) {
res.push([]);
for (let j = 0; j < d1; j++) {
res[i].push([]);
for (let k = 0; k < d2; k++) {
res[i][j].push([]);
for (let l = 0; l < d3; l++) {
res[i][j][k].push(it.next().value);
}
}
}
}
return res;
};
const getDefaultQkResults = async () => {
const request = await fetch('default_qk_results.dat');
const buffer = await request.arrayBuffer();
const array = [...new Float32Array(buffer)];
const array4D = reshapeList4D(array, 12, 12, 24, 24);
return array4D;
};