通过密集层传递3D张量时,我看到了以下实现方式:
X = np.random.rand(5,4,3).astype(np.float32)
place = tf.placeholder(shape=[None, None, 3], dtype=tf.float32)
dense = tf.layers.dense(place, 10)
另一方面,我也看到了这一点:
X = np.random.rand(5,4,3).astype(np.float32)
place = tf.placeholder(shape=[None, None, 3], dtype=tf.float32)
place_reshape = tf.reshape(place, [tf.shape(place)[0] * tf.shape(place)[1], 3])
dense = tf.layers.dense(place_reshape, 10)
dense_reshape = tf.reshape(dense, [tf.shape(place)[0], tf.shape(place)[1], 10])
尽管这两种方法本质上应该是相同的,但是即使我同时设置了两个随机种子,我也无法获得相同的结果(出于可读性考虑,我已将它们从代码片段中省略了)。有人可以指出我正确的方向吗?
期待您的回答!