-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpickle_2_mat.py
33 lines (24 loc) · 1.18 KB
/
pickle_2_mat.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
import scipy.io
import numpy as np
import pickle
image_size = 128
num_labels = 3
def reformat(dataset, labels):
dataset = dataset.reshape((-1, image_size * image_size)).astype(np.float32)
# Map 0 to [1.0, 0.0, 0.0 ...], 1 to [0.0, 1.0, 0.0 ...]
#labels = (np.arange(num_labels) == labels[:,None]).astype(np.float32)
return dataset, labels
f = open('/home/master/Desktop/weapons_complex/ATR_FNN/final_dataset.pickle', 'rb')
final_dataset = pickle.load(f)
train_dataset, train_labels = reformat(final_dataset['train_dataset'], final_dataset['train_labels'])
valid_dataset, valid_labels = reformat(final_dataset['valid_dataset'], final_dataset['valid_labels'])
test_dataset, test_labels = reformat(final_dataset['test_dataset'], final_dataset['test_labels'])
scipy.io.savemat('/home/master/Desktop/GIT/ATR-FNN/final_dataset.mat',
mdict={'train_dataset': train_dataset,
'train_labels': train_labels,
'valid_dataset': valid_dataset,
'valid_labels': valid_labels,
'test_dataset': test_dataset,
'test_labels': test_labels
})
f.close()