纪元数与历史不符

时间:2019-10-30 12:33:45

标签: python keras neural-network

执行gridsearchcv之后,我使用最佳估算器再次拟合数据:

X_train1_be, X_val1_be, y_train1_be, y_val1_be = train_test_split(X_train1, y_train1, test_size=0.2, shuffle=False)

epochs = [1, 3, 5, 7, 10]
grid_best = grid_result.best_estimator_
history = grid_best.fit(X_train1_be, y_train1_be
                        , callbacks = [
                                       EarlyStopping()
                                       , time_callback = TimeHistory()
                                      ]
                        , validation_data=(X_val1_be, y_val1_be)
                        , epochs = max(epochs)*3
                        )

现在的问题是我不了解history对象的输出:

history.history['loss']
[0.8300184490816558,
 0.5283153956098592,
 0.449094379786402,
 0.4157974881613079,
 0.38849579829120023,
 0.3627836440196809,
 0.3339067582753213]

应该没有30个值吗?或至少10个? 重新计算时,之后我通常只会得到两个值,但有时确实是根据fit.()中给出的实际时期数得出的。但大多只有两个值。 我绝对不理解这种随机行为。我只重复history = grid_best.fit(...)并得到大多数任意结果。当我从头开始重复整个代码时,我至少会得到两个以上的值(但像上面一样,也没有达到应有的值(?)。)

0 个答案:

没有答案