forked from pcafrica/electrophysiology_solver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreprocess_data.py
More file actions
executable file
·37 lines (31 loc) · 1.33 KB
/
preprocess_data.py
File metadata and controls
executable file
·37 lines (31 loc) · 1.33 KB
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
import numpy as np
import os
from tqdm import tqdm
import torch
proc_numbers = ['00', '01', '02', '03', '04', '05', '06', '07']
tensors_names = ["w_", "u_"]
for n in proc_numbers:
directory = 'build_inference/'
times = []
all_data = None
points = torch.jit.load('build_inference/points_' + n + '.pt')
points = list(points.parameters())[0]
torch.save(points, 'data/points_'+n+'.pt')
edge_index = torch.jit.load('build_inference/edges_' + n + '.pt')
edge_index = list(edge_index.parameters())[0]
torch.save(edge_index, 'data/edges_'+n+'.pt')
edge_attr = torch.jit.load('build_inference/attr_' + n + '.pt')
edge_attr = list(edge_attr.parameters())[0]
torch.save(edge_attr, 'data/attr_'+n+'.pt')
directory = directory + 'snapshot/'
for name in tensors_names:
file_names = sorted([f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f)) and f.endswith(n+'.pt') and name in f])
all_data = None
for file in tqdm(file_names):
tensor = torch.jit.load(directory + file)
tensor = list(tensor.parameters())[0].unsqueeze(0)
if all_data is None:
all_data = tensor
else:
all_data = torch.vstack([all_data, tensor])
torch.save(all_data, "data/"+name+n+'.pt')