-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnpy_to_mmap.py
More file actions
29 lines (27 loc) · 1006 Bytes
/
npy_to_mmap.py
File metadata and controls
29 lines (27 loc) · 1006 Bytes
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
import numpy as np
import os
import util as UM
import sys
basedir = '/nfs/guille/eecs_research/soundbendor/kwand/mtmidi/acts2/'
acts_folder = 'acts'
cur_dataset = sys.argv[1]
cdir = os.path.join(basedir, cur_dataset)
use_64bit = False
acts = os.listdir(cdir)
for actdir in acts:
actpath = os.path.join(cdir,actdir)
cur_num_layers = UM.get_embedding_num_layers(actdir)
for f in os.listdir(actpath):
fpath = os.path.join(actpath, f)
cur_np = np.load(fpath)
#cur_f = f
#if f.dtype == 'float64':
#print('64bit')
print(actpath, cur_num_layers)
new_fname = UM.ext_replace(f, 'dat')
print(f'processing {new_fname} in {actdir}')
cur_f = cur_np.astype(np.float32)
shape = cur_f.shape
emb_file = UM.get_embedding_file(actdir, acts_folder=acts_folder, dataset=cur_dataset, fname=new_fname, use_64bit = use_64bit, write=True, use_shape = shape)
emb_file[:] = cur_f[:]
print('cur_f', cur_f.dtype)