parameters: (X, y)
return_statement: return learn.models.logistic_regression(encoding, y)
docstring: Recurrent neural network model to predict from sequence of words
      to a class.
docstring_summary: Recurrent neural network model to predict from sequence of words
      to a class.
docstring_tokens: Recurrent neural network model to predict from sequence of words to a class .
function: def rnn_model(X, y):
    """Recurrent neural network model to predict from sequence of words
      to a class."""
    # Convert indexes of words into embeddings.
    # This creates embeddings matrix of [n_words, EMBEDDING_SIZE] and then
    # maps word indexes of the sequence into [batch_size, sequence_length,
    # EMBEDDING_SIZE].
    word_vectors = learn.ops.categorical_variable(X, n_classes=n_words,
        embedding_size=EMBEDDING_SIZE, name='words')
    # Split into list of embedding per word, while removing doc length dim.
    # word_list results to be a list of tensors [batch_size, EMBEDDING_SIZE].
    word_list = tf.unpack(word_vectors, axis=1)
    # Create a Gated Recurrent Unit cell with hidden size of EMBEDDING_SIZE.
    cell = tf.nn.rnn_cell.GRUCell(EMBEDDING_SIZE)
    # Create an unrolled Recurrent Neural Networks to length of
    # MAX_DOCUMENT_LENGTH and passes word_list as inputs for each unit.
    _, encoding = tf.nn.rnn(cell, word_list, dtype=tf.float32)
    # Given encoding of RNN, take encoding of last step (e.g hidden size of the
    # neural network of last step) and pass it as features for logistic
    # regression over output classes.
    return learn.models.logistic_regression(encoding, y)
function_tokens: def rnn_model ( X , y ) : # Convert indexes of words into embeddings. # This creates embeddings matrix of [n_words, EMBEDDING_SIZE] and then # maps word indexes of the sequence into [batch_size, sequence_length, # EMBEDDING_SIZE]. word_vectors = learn . ops . categorical_variable ( X , n_classes = n_words , embedding_size = EMBEDDING_SIZE , name = 'words' ) # Split into list of embedding per word, while removing doc length dim. # word_list results to be a list of tensors [batch_size, EMBEDDING_SIZE]. word_list = tf . unpack ( word_vectors , axis = 1 ) # Create a Gated Recurrent Unit cell with hidden size of EMBEDDING_SIZE. cell = tf . nn . rnn_cell . GRUCell ( EMBEDDING_SIZE ) # Create an unrolled Recurrent Neural Networks to length of # MAX_DOCUMENT_LENGTH and passes word_list as inputs for each unit. _ , encoding = tf . nn . rnn ( cell , word_list , dtype = tf . float32 ) # Given encoding of RNN, take encoding of last step (e.g hidden size of the # neural network of last step) and pass it as features for logistic # regression over output classes. return learn . models . logistic_regression ( encoding , y )