-
Notifications
You must be signed in to change notification settings - Fork 172
/
Data_Generation_Y.py
98 lines (62 loc) · 2.28 KB
/
Data_Generation_Y.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
96
97
98
# -*- coding: utf-8 -*-
import numpy as np
#%% Corresponding Y generation
def Syn_Generation_Y1(X, W, sigma):
# No of samples
n = len(X)
t = len(X[0][:,0])
# Initialization
Output_Y = list()
for i in range(n):
Temp_X = X[i]
Temp_Y = np.zeros([t,])
for j in range(t):
Temp_Y[j] = np.exp(-np.abs(np.sum(W * Temp_X[j,:]))) + np.random.normal(loc = 0, scale = sigma)
Output_Y.append(Temp_Y)
return Output_Y
#%% Corresponding Y generation
def Syn_Generation_Y2(X, W, sigma):
# No of samples
n = len(X)
t = len(X[0][:,0])
d = int(len(X[0][0,:])/2)
# Initialization
Output_Y = list()
for i in range(n):
Temp_X = X[i]
Temp_Y = np.zeros([t,])
for j in range(t):
Temp_Y[j] = np.exp(-np.abs(np.sum(W * Temp_X[j,:d]))) + np.random.normal(loc = 0, scale = sigma)
Output_Y.append(Temp_Y)
return Output_Y
#%% Corresponding Y generation
def Syn_Generation_Y3(X, W, sigma, eta):
# No of samples
n = len(X)
t = len(X[0][:,0])
d = int(len(X[0][0,:])/2)
# Initialization
Output_Y = list()
for i in range(n):
Temp_X = X[i]
Temp_Y = np.zeros([t,])
for j in range(t):
Temp_Y[j] = np.exp(-np.abs(np.sum(W * Temp_X[j,:d]))) + np.random.normal(loc = 0, scale = sigma)
Output_Y.append(Temp_Y)
#%% Cost Generation
Output_C = list()
Output_G = list()
for i in range(n):
Temp = X[i].copy()
Temp_Y = Output_Y[i]
Temp_G = X[i].copy()
for j in range(t):
if (Temp_Y[j] < 0.5):
Temp[j,:] = np.asarray([1,1,1,1,1,1,1,1,1,1,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2])
Temp_G[j,:] = np.asarray([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
else:
Temp[j,:] = eta * np.asarray([1,1,1,1,1,1,1,1,1,1,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2])
Temp_G[j,:] = np.asarray([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1])
Output_C.append(Temp)
Output_G.append(Temp_G)
return Output_Y, Output_C, Output_G