siame_resnet()の入力のDimが4096なのですが、入力データDim(4069,)にしていたのが大きな要因でした。夜遅くのDebugは禁ですね。
from keras import backend as K
import tensorflow as tf
from keras.layers import Lambda
seq_model = siame_resnet()
seq_model.load_weights(model_path, by_name=True)
def euclidean_distance2(vects):
x, y = vects
return K.abs(x - y)
def model_lambda(x,y):
x_=tf.convert_to_tensor(x)
y_=tf.convert_to_tensor(y)
xy_result=Lambda(euclidean_distance2)([x,y_])
_xy_result = tf.reshape(_xy_result,((1,4096)))
result=seq_model(_xy_result)
return result
def siame_resnet_():
seq = models.Sequential()
seq.add(Dense(1024, activation='sigmoid', input_shape=(4096,)))
seq.add(Dropout(0.20))
seq.add(Dense(1024, activation='sigmoid', input_shape=(1024,)))
seq.add(Dense(1, activation='sigmoid'))
return seq
本体の関数読み出し
result=model_lambda(A,B)
_result=K.get_value(result)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/04/06 16:27