0

我想要一個應用程序來證明我自己的RNN。最簡單的應用程序最簡單的RNN?

我只寫自己最簡單的RNN 沒有 tensorflow。

所以我需要一個簡單的RNN應用程序來確保實現是正確的。越簡單越好。

例如,我可以使用MNIST來證明我自己的CNN。

謝謝。

+0

我不明白downvotes。 –

回答

0

看到一個簡單的模型RNN

def model(X, W, B, lstm_size): 
    # X, input shape: (batch_size, time_step_size, input_vec_size) 
    XT = tf.transpose(X, [1, 0, 2]) # permute time_step_size and batch_size 
    # XT shape: (time_step_size, batch_size, input_vec_size) 
    XR = tf.reshape(XT, [-1, lstm_size]) # each row has input for each lstm cell (lstm_size=input_vec_size) 
    # XR shape: (time_step_size * batch_size, input_vec_size) 
    X_split = tf.split(0, time_step_size, XR) # split them to time_step_size (28 arrays) 
    # Each array shape: (batch_size, input_vec_size) 

    # Make lstm with lstm_size (each input vector size) 
    lstm = tf.nn.rnn_cell.BasicLSTMCell(lstm_size, forget_bias=1.0, state_is_tuple=True) 

    # Get lstm cell output, time_step_size (28) arrays with lstm_size output: (batch_size, lstm_size) 
    outputs, _states = tf.nn.rnn(lstm, X_split, dtype=tf.float32) 

    # Linear activation 
    # Get the last output 
    return tf.matmul(outputs[-1], W) + B, lstm.state_size # State size to initialize the stat 

你可以找到更多的例子從https://github.com/nlintz/TensorFlow-Tutorials/

相關問題