GRU และ LSTM cells

Recurrent Neural Networks (RNNs) สำหรับ Language Modeling ด้วย Keras

David Cecchini

Data Scientist

ภาพขยาย SimpleRNN memory cell แสดง memory state ที่รับมาจาก cell ก่อนหน้าและอินพุตของคำถัดไป cell ส่งออก memory state ใหม่และการทำนาย

Recurrent Neural Networks (RNNs) สำหรับ Language Modeling ด้วย Keras

ภาพขยาย GRU cell แสดงโครงสร้างที่เพิ่มเข้ามาคือ update gate และ initial candidate for memory cell

Recurrent Neural Networks (RNNs) สำหรับ Language Modeling ด้วย Keras

ภาพขยาย LSTM cell แสดง forget gate, output gate, update gate และ candidate for memory cell ที่เพิ่มเข้ามา

Recurrent Neural Networks (RNNs) สำหรับ Language Modeling ด้วย Keras

ไม่มี vanishing gradient อีกต่อไป

  • simpleRNN cell อาจมีปัญหา gradient

    • เมทริกซ์น้ำหนักยกกำลัง t คูณกับพจน์อื่น
  • GRU และ LSTM cell ไม่มีปัญหา vanishing gradient

    • เพราะมี gate ช่วยควบคุม
    • ไม่มีพจน์เมทริกซ์น้ำหนักคูณกับส่วนที่เหลือ
    • ปัญหา exploding gradient แก้ได้ง่ายกว่า
Recurrent Neural Networks (RNNs) สำหรับ Language Modeling ด้วย Keras

การใช้งานใน Keras

# Import the layers
from tensorflow import keras
from tensorflow.keras.layers import GRU, LSTM
# Add the layers to a model
model.add(GRU(units=128, return_sequences=True, name='GRU layer'))
model.add(LSTM(units=64, return_sequences=False, name='LSTM layer'))
Recurrent Neural Networks (RNNs) สำหรับ Language Modeling ด้วย Keras

มาฝึกกันเถอะ!

Recurrent Neural Networks (RNNs) สำหรับ Language Modeling ด้วย Keras

Preparing Video For Download...