グリッドサーチを実行すると、実行結果(過程)が、ズラズラ~と表示されます。
これを、最終行のベストパラメータとscoreだけ(2行だけ)表示するにはどうすればよいでしょうか?
よろしくお願いいたします。
# グリッドサーチ(実行) from keras.wrappers.scikit_learn import KerasClassifier from sklearn.model_selection import GridSearchCV # KerasClassifier/KerasRegressor can be used as same as scikit_learn estimator. model = KerasClassifier(build_fn=create_model) # Grid Search parameters (epochs, batch size and optimizer) optimizers = ['adam'] init = [ 'normal'] epochs = [10] batches = [5] param_grid = dict(optimizer=optimizers, epochs=epochs, batch_size=batches, init=init) grid = GridSearchCV(estimator=model, param_grid=param_grid) grid_result = grid.fit(x_train_std, y_train) # summarize results # print("Best parameter set: {}".format(grid_result.best_params_)) print(grid.best_params_) print(grid.best_score_) Epoch 1/10 320/320 [==============================] - 4s 12ms/step - loss: 0.4890 - acc: 0.7875 Epoch 2/10 320/320 [==============================] - 0s 477us/step - loss: 0.4209 - acc: 0.8156 Epoch 3/10 320/320 [==============================] - 0s 479us/step - loss: 0.3637 - acc: 0.8406 Epoch 4/10 320/320 [==============================] - 0s 468us/step - loss: 0.3355 - acc: 0.8469 Epoch 5/10 320/320 [==============================] - 0s 461us/step - loss: 0.3141 - acc: 0.8469 Epoch 6/10 320/320 [==============================] - 0s 470us/step - loss: 0.2729 - acc: 0.8938 Epoch 7/10 320/320 [==============================] - 0s 465us/step - loss: 0.2629 - acc: 0.8844 Epoch 8/10 320/320 [==============================] - 0s 466us/step - loss: 0.2447 - acc: 0.9094 Epoch 9/10 320/320 [==============================] - 0s 467us/step - loss: 0.2171 - acc: 0.9000 Epoch 10/10 320/320 [==============================] - 0s 469us/step - loss: 0.2007 - acc: 0.9250 160/160 [==============================] - 2s 10ms/step Epoch 1/10 320/320 [==============================] - 4s 12ms/step - loss: 0.5110 - acc: 0.7438 Epoch 2/10 320/320 [==============================] - 0s 625us/step - loss: 0.4325 - acc: 0.7875 Epoch 3/10 320/320 [==============================] - 0s 700us/step - loss: 0.3702 - acc: 0.8313 Epoch 4/10 320/320 [==============================] - 0s 642us/step - loss: 0.3597 - acc: 0.8375 Epoch 5/10 320/320 [==============================] - 0s 636us/step - loss: 0.3022 - acc: 0.8813 Epoch 6/10 320/320 [==============================] - 0s 634us/step - loss: 0.2885 - acc: 0.8844 Epoch 7/10 320/320 [==============================] - 0s 649us/step - loss: 0.2553 - acc: 0.9063 Epoch 8/10 320/320 [==============================] - 0s 647us/step - loss: 0.2383 - acc: 0.9094 Epoch 9/10 320/320 [==============================] - 0s 690us/step - loss: 0.2311 - acc: 0.8906 Epoch 10/10 320/320 [==============================] - 0s 654us/step - loss: 0.2031 - acc: 0.9375 160/160 [==============================] - 2s 10ms/step Epoch 1/10 320/320 [==============================] - 4s 12ms/step - loss: 0.5758 - acc: 0.7313 Epoch 2/10 320/320 [==============================] - 0s 739us/step - loss: 0.4505 - acc: 0.8094 Epoch 3/10 320/320 [==============================] - 0s 826us/step - loss: 0.3628 - acc: 0.8344 Epoch 4/10 320/320 [==============================] - 0s 650us/step - loss: 0.3599 - acc: 0.8469 Epoch 5/10 320/320 [==============================] - 0s 655us/step - loss: 0.3309 - acc: 0.8563 Epoch 6/10 320/320 [==============================] - 0s 640us/step - loss: 0.2848 - acc: 0.8844 Epoch 7/10 320/320 [==============================] - 0s 660us/step - loss: 0.2653 - acc: 0.8969 Epoch 8/10 320/320 [==============================] - 0s 641us/step - loss: 0.2523 - acc: 0.9094 Epoch 9/10 320/320 [==============================] - 0s 672us/step - loss: 0.2239 - acc: 0.9219 Epoch 10/10 320/320 [==============================] - 0s 530us/step - loss: 0.1995 - acc: 0.9469 160/160 [==============================] - 2s 10ms/step Epoch 1/10 480/480 [==============================] - 4s 8ms/step - loss: 0.5254 - acc: 0.7667 Epoch 2/10 480/480 [==============================] - 0s 534us/step - loss: 0.4089 - acc: 0.8188 Epoch 3/10 480/480 [==============================] - 0s 523us/step - loss: 0.3696 - acc: 0.8292 Epoch 4/10 480/480 [==============================] - 0s 553us/step - loss: 0.3448 - acc: 0.8396 Epoch 5/10 480/480 [==============================] - 0s 551us/step - loss: 0.3042 - acc: 0.8833 Epoch 6/10 480/480 [==============================] - 0s 548us/step - loss: 0.2843 - acc: 0.8792 Epoch 7/10 480/480 [==============================] - 0s 525us/step - loss: 0.2667 - acc: 0.9000 Epoch 8/10 480/480 [==============================] - 0s 506us/step - loss: 0.2410 - acc: 0.9125 Epoch 9/10 480/480 [==============================] - 0s 520us/step - loss: 0.2372 - acc: 0.9042 Epoch 10/10 480/480 [==============================] - 0s 512us/step - loss: 0.2076 - acc: 0.9313 {'batch_size': 5, 'epochs': 10, 'init': 'normal', 'optimizer': 'adam'} 0.8062500103066365
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/10/29 07:48