-
Notifications
You must be signed in to change notification settings - Fork 1
/
LoadData.py
95 lines (50 loc) · 2.06 KB
/
LoadData.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Video Synthesis via Transform-Based Tensor Neural Network
# Yimeng Zhang
# 8/4/2020
import tensorflow as tf
import scipy.io as sio
import numpy as np
import DefineParam as DP
import h5py
# Get param
pixel_w, pixel_h, batchSize, nPhase, nTrainData, nValData, learningRate, nEpoch, nOfModel, ncpkt, trainFile, valFile, testFile, saveDir, modelDir = DP.get_param()
# Training Data Loading
def load_train_data(mat73=False):
if mat73 == True:
trainData = h5py.File(trainFile)
trainLabel = np.transpose(trainData['sub_data'], [3, 2, 1, 0])
else:
trainData = sio.loadmat(trainFile)
trainLabel = trainData['sub_data']
if mat73 == True:
valData = h5py.File(valFile)
valLabel = np.transpose(valData['sub_data'], [3, 2, 1, 0])
else:
valData = sio.loadmat(valFile)
valLabel = valData['sub_data']
print("nOfModel: %d" % nOfModel)
print(np.shape(trainLabel))
del trainData
del valData
return trainLabel, valLabel
# Testing Data Loading
def load_test_data(mat73=False):
if mat73 == True:
testData = h5py.File(testFile)
testLabel = np.transpose(testData['sub_data'], [3, 2, 1, 0])
else:
testData = sio.loadmat(testFile)
testLabel = testData['sub_data'] # labels
print(np.shape(testLabel))
del testData
return testLabel
# Essential Computations
def pre_calculate(phi):
Xinput = tf.placeholder(tf.float32, [None, pixel_h, pixel_w, nOfModel]) # After Init
Xoutput = tf.placeholder(tf.float32, [None, pixel_h, pixel_w, nOfModel])
Yinput = tf.placeholder(tf.float32, [None, pixel_h, pixel_w, nOfModel]) # After sampling
Epoch_num = tf.placeholder(tf.float32)
Phi = tf.constant(phi)
PhiT = Phi
return Xinput, Xoutput, Phi, PhiT, Yinput, Epoch_num