區別在於,dense層就沒有 隱藏狀態,而RNN由於隱藏狀態的存在,使得前後時間序列產生了聯繫
import tensorflow as tf
import numpy as np
X, W_xh = tf.random.normal(shape=(3, 1)), tf.random.normal(shape=(1, 4))
H, W_hh = tf.random.normal(shape=(3, 4)), tf.random.normal(shape=(4, 4))
tf.matmul(X, W_xh) + tf.matmul(H, W_hh)