梯度爆炸,损耗南,精度为零

时间:2020-05-16 10:22:10

标签: python tensorflow keras deep-learning nan

我正在得到Nan损失和0精度。我正在使用fit_generator Keras拟合我的模型。而且我的输入中没有任何NaN。

DISTINCT ON

这是我使用自定义生成器拟合模型的方式:

SELECT DISTINCT ON (contract_id) *
FROM contract_versions
WHERE client_id = 1
ORDER BY 
  contract_id,
  CASE WHEN change_effective_date <= CURRENT_DATE THEN 1 ELSE 2 END,
  change_effective_date DESC;

归一化功能:

n_timesteps, n_features, n_outputs = 50, 59, 7000
model=Sequential()
model.add(LSTM(16 ,kernel_regularizer=l2(0.1), recurrent_regularizer=l2(0.1),      
bias_regularizer=l2(0.1),input_shape=(n_timesteps,n_features)))
model.add(Dropout(0.2))
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(n_outputs, activation='softmax'))
model.compile(loss='sparse_categorical_crossentropy', optimizer=keras.optimizers.RMSprop(),   metrics=['accuracy'])

0 个答案:

没有答案