0
我想實現一個RNN而不使用tensorflow提供的RNN功能。這裏是我試過的代碼,最終給我一個錯誤在Tensorflow中創建高度可定製的RNN
import tensorflow as tf
tf.InteractiveSession()
x = tf.placeholder(tf.float32, shape=(5,5))
InitialState = tf.zeros((5,1))
h = InitialState
W1 = tf.Variable(tf.random_normal([5, 5], stddev=0.35),
name="W1")
W2 = tf.Variable(tf.random_normal([5, 5], stddev=0.35),
name="W2")
for k in range(5):
h = tf.matmul(W1,h) + tf.matmul(W2,x[:,k:(k+1)])
h = tf.sigmoid(h)
with tf.Session() as sess:
sess.run(tf.initialize_all_variables())
a = sess.run([h], feed_dict = {x:tf.ones((5,5))})
如何從零開始實現RNN?網上有例子嗎?
1)我們不知道你得到了什麼錯誤2)如何實現RNN的最好的例子是張量本身的實際RNN實現。 – runDOSrun