forked from ucsd-hep-ex/L1METML
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
25 lines (18 loc) · 863 Bytes
/
Copy pathmodels.py
File metadata and controls
25 lines (18 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import keras
from keras.models import Model
from keras.layers import Input, Dense, BatchNormalization, Dropout, Lambda
from keras.backend import slice
def dense(ninputs, noutputs):
inputs = Input(shape=(ninputs,), name = 'input')
#x = BatchNormalization(name='bn_1')(inputs)
x = Dense(64, name = 'dense_1', activation='relu')(inputs)
x = Dropout(rate=0.1)(x)
x = Dense(32, name = 'dense_2', activation='relu')(x)
x = Dropout(rate=0.1)(x)
x = Dense(32, name = 'dense_3', activation='relu')(x)
x = Dropout(rate=0.1)(x)
outputs = Dense(noutputs, name = 'output', activation='linear')(x)
outputs0 = Lambda(lambda x: slice(x, (0, 0), (-1, 1)))(outputs)
outputs1 = Lambda(lambda x: slice(x, (0, 1), (-1, -1)))(outputs)
keras_model = Model(inputs=inputs, outputs=[outputs0, outputs1])
return keras_model