forked from zclod/GenderRecognition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
siamese.py
31 lines (23 loc) · 750 Bytes
/
siamese.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
__author__ = 'marco'
from keras.models import Sequential
from keras.layers.core import Dense, Siamese
def build_siamese(input_model_1, input_model_2, input_dim, output_dim):
"""
:param input_model_1:
:type input_model_1:
:param input_model_2:
:type input_model_2:
:param input_dim: last layer input
:type input_dim:
:param output_dim: last layer output
:type output_dim:
:return:
:rtype:
"""
inputs = [input_model_1, input_model_2]
layer = Dense(input_dim=input_dim, output_dim=output_dim)
model = Sequential()
# mode: one of {sum, mul, concat, ave, join, cos, dot}.
model.add(Siamese(layer, inputs, 'sum'))
# model.compile(loss='mse', optimizer='sgd')
return model