TensorFlow (Google) framework học máy mã nguồn mở. Cài đặt: pip install tensorflow.
IMDB dataset: >50.000 review phim, dùng cho NLP.
Chạy trên Google Colab (Python trên trình duyệt, GPU miễn phí).
Ví dụ
history_dict = history.history
history_dict.keys()
acc = history_dict['binary_accuracy']
val_acc = history_dict['val_binary_accuracy']
loss = history_dict['loss']
val_loss = history_dict['val_loss']
epochs = range(1, len(acc) + 1)
plt.plot(epochs, loss, 'ro', label='Training loss')
plt.plot(epochs, val_loss, 'b', label='Validation loss')
plt.title('Training and validation loss with respect to time')
plt.xlabel('Epochs')
plt.ylabel('Loss')
plt.legend()
plt.show()
Nguồn mã: TensorFlow Text Classification
Đầu ra

Giải thích
- Sau fit mô hình, so sánh giá trị thực/dự đoán qua trực quan hóa.
- Dùng matplotlib vẽ loss train/validation theo epochs.
- Dựa trên số bước (epochs) huấn luyện.