tf.nn.dynamic_rnn 函数是tensorflow封装的用来实现递归神经网络(RNN)的函数,
本文会重点讨论一下tf.nn.dynamic_rnn 函数的参数及返回值。
注意:这是tf1的写法,在tf2中执行的,只是讨论一下输出,并不是完整案例,完整参考TensorFlow 2 Tutorial: Get Started in Deep Learning With tf.keras。
import tensorflow as tf
import numpy as np
X = np.random.randn(3, 6, 4)
X[1, 4:] = 0
X_lengths = [6, 4, 6]
rnn_hidden_size = 5
cell = tf.comp