forked from saeedahmadian/GAN_Auto_Encoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.py
More file actions
41 lines (29 loc) · 1.42 KB
/
Copy pathdata.py
File metadata and controls
41 lines (29 loc) · 1.42 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
38
39
40
import numpy as np
class CyberData(object):
def __init__(self, config):
self.num_samples = config.num_samples
self.num_features = config.num_features
self.num_nodes = config.num_nodes
mean = 100
std = 20
# create array for data
self.X = np.zeros((self.num_samples, self.num_nodes, self.num_features, 1), dtype='float32')
# Data for Auto_encoder
self.X_Auto = np.zeros((self.num_samples, self.num_nodes, self.num_features, 1), dtype='float32')
# generate user data from Gaussian distribution
for n in range(self.num_samples):
for i in range(self.num_nodes):
self.X[n, i, :, 0] = np.random.normal(loc=mean, scale=std, size=self.num_features)
self.y = np.zeros((self.num_samples, 1)).astype('float32')
def next_batch(self, batch_size):
""" get next batch of samples"""
for i in range(0, self.num_samples, batch_size):
yield self.X[i: i + batch_size, :, :], self.y[i: i + batch_size], self.X_Auto[i: i + batch_size, :, :]
def randomize(self):
""" Randomizes the order of data samples and their corresponding labels"""
permutation = np.random.permutation(self.X.shape[0])
self.X = self.X[permutation, :, :, :]
self.X_Auto = self.X_Auto[permutation, :, :, :]
self.y = self.y[permutation, :]
if __name__ == '__main__':
data = CyberData()