我正在得到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'])