Нет обновления модели Кераса потерь и точности, похоже, что обратная опора не происходит - PullRequest
0 голосов
/ 18 июня 2020

Я пытаюсь построить простую модель в Keras, которая занимает 512 лен вектора, here's the schematic of the model

Код:

 max_seq_length=512
 def exponent_neg_manhattan_distance(left, right):
    ''' Helper function for the similarity estimate of the LSTMs outputs'''
    return K.exp(-K.sum(K.abs(left-right), axis=1, keepdims=True))

  # The visible layer
  left_input = Input(shape=(max_seq_length,), dtype='int32')
  right_input = Input(shape=(max_seq_length,), dtype='int32')

  model = Sequential()
  model.add(Dense(256, input_dim=512, activation='sigmoid'))
  model.add(Dense(128, activation='relu'))
  model.add(Dense(64, activation='relu'))

  shared_network = model

  left_output = shared_network(left_input)
  right_output = shared_network(right_input)

  mal_distance = Lambda(function=lambda x: exponent_neg_manhattan_distance(x[0], 
                 x[1]),output_shape=lambda x: (x[0][0], 1))([left_output, right_output])
  # Pack it all up into a model
  mal_network = Model([left_input, right_input], [mal_distance])

  optimizer = Adadelta(clipnorm=1.25, learning_rate=0.1)

  # compile the keras model
  mal_network.compile(loss='mean_squared_error', optimizer=optimizer, metrics=['accuracy'])

  mal_network.summary()

I ' m не уверен, где я делаю ошибку, потери и точность не меняются за итерацию. Ниже показан результат, пока я обучаю модель: loss and accuracy of the model

...