28.04.2020 Views

Sách Deep Learning cơ bản

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

214 Chương 17. Ứng dụng thêm mô tả cho ảnh

17.5.3 Word embedding

Pre-trained GLOVE Model được sử dụng cho quá trình word embedding.

Mọi người vào link này để tải file glove.6B.zip

Từng dòng trong file sẽ lưu text và encoded vector khích thước 200*1

17.5.4 Output

17.5.5 Model

Bài toán là dự đoán từ tiếp theo trong chuỗi ở input với ảnh hiện tại, nên output là từ nào trong số 1652

từ trong từ điển mà ta có. Với bài toán phân loại thì softmax activation và categorical_crossentropy

loss function được sử dụng.

==========================================================================================

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

__________________________________________________________________________________________

==========================================================================================

Layer (type) Output Shape Param # Connected to

input_3 (InputLayer) (None, 34) 0

input_2 (InputLayer) (None, 2048) 0

embedding_1 (Embedding) (None, 34, 200) 330400 input_3[0][0]

dropout_1 (Dropout) (None, 2048) 0 input_2[0][0]

dropout_2 (Dropout) (None, 34, 200) 0 embedding_1[0][0]

dense_1 (Dense) (None, 256) 524544 dropout_1[0][0]

lstm_1 (LSTM) (None, 256) 467968 dropout_2[0][0]

add_1 (Add) (None, 256) 0 dense_1[0][0]

lstm_1[0][0]

dense_2 (Dense) (None, 256) 65792 add_1[0][0]

dense_3 (Dense) (None, 1652) 424564 dense_2[0][0]

Total params: 1,813,268

Trainable params: 1,813,268

Non-trainable params: 0

17.6 Python code

# -*- coding: utf-8 -*-

# Commented out IPython magic to ensure Python compatibility.

# Thêm thư viện

import numpy as np

from numpy import array

import pandas as pd

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!