-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_model.py
More file actions
21 lines (16 loc) · 786 Bytes
/
Copy pathinput_model.py
File metadata and controls
21 lines (16 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from tensorflow.keras import Model, Input
from tensorflow.keras.layers import Lambda
#First model to get x_i from the input: (x_1,...,x_d)
def model_input(d):
input = Input(shape=(d,))
output = {}
for i in range(1, d + 1): # Get each node from the input
output[f'x_{i}'] = Lambda(lambda x: x[:, i - 1:i])(input)
result = {} #For each x_i we make one model and put it in a dictionary
for i in range(1,d+1):
result[f'x_{i}'] = Model(inputs = input,
outputs = output[f'x_{i}'],
name = f'input_x_{i}')
return result
# So model_input = {x_1: Model(input=(x_1,...,x_d), output = x_1), x_2: ....}
# This way we can split the inputs and compute phi_K(x_q) for q = 1,...,d