Keras


Keras 基本事項

compile

model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['acc'])

fit

history = model.fit(x, y, validation_split=0.25, epochs=50, batch_size=16, verbose=1)

evaluate

訓練したモデルの評価を行う

predict

訓練したモデルを使って、実際に個別のデータに対して性能を見る。

save

結果を描画する

fitが返すHistoryオブジェクトから損失率、正解率を描画することができる。

plt.plot(history.history['acc'])
plt.plot(history.history['val_acc'])
plt.legend(['Train', 'Test'], loc='upper left')
plt.savefig("acc.png")

また、DataFrameに変換してから描画することもできる。

df_history = pd.DataFrame(history.history)
df_history.plot()
plt.savefig()

RNN LSTMによる文章分類