区别在于,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)