forked from google-research/slip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_test_data.py
33 lines (25 loc) · 893 Bytes
/
make_test_data.py
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
"""Utilities for writing mock test files."""
import numpy as np
import utils
from pathlib import Path
test_set_dir = 'test_data/test_sets'
mock_test_set_filepath = Path(test_set_dir) / 'fakepdb' / 'test_set_1.npz'
mock_mogwai_filepath = 'test_data/fakepdb_model_state_dict.npz'
L = 3
A = 5
def write_mock_mogwai_state_dict():
# linear landscape, all singles are adaptive
query_seq = np.zeros(L, dtype=np.int32)
bias = np.zeros((L, A)) - utils.onehot(query_seq, num_classes=A)
weight = np.zeros((L, A, L, A))
state_dict = {
'bias': bias,
'weight': weight,
'query_seq': query_seq,
}
with open(mock_mogwai_filepath, 'wb') as f:
np.savez(f, **state_dict)
def write_mock_test_set():
test_seq = np.arange(L, dtype=np.int32)
with open(mock_test_set_filepath, 'wb') as f:
np.savez(f, sequences=np.array([test_seq,]))