def main(): import problem_unittests as tests tests.test_get_init_cell(get_init_cell) tests.test_get_embed(get_embed) tests.test_build_rnn(build_rnn) tests.test_build_nn(build_nn) tests.test_get_batches(get_batches) tests.test_get_tensors(get_tensors) tests.test_pick_word(pick_word) print(get_batches([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], batch_size=3, seq_length=2))
def run_test(): import problem_unittests as t t.test_create_lookup_tables(create_lookup_tables) t.test_get_batches(get_batches) t.test_tokenize(token_lookup) t.test_get_inputs(get_inputs) t.test_get_init_cell(get_init_cell) t.test_get_embed(get_embed) t.test_build_rnn(build_rnn) t.test_build_nn(build_nn) t.test_get_tensors(get_tensors) t.test_pick_word(pick_word)
Create embedding for <input_data>. :param input_data: TF placeholder for text input. :param vocab_size: Number of words in vocabulary. :param embed_dim: Number of embedding dimensions :return: Embedded input. """ # TODO: Implement Function embeddings = tf.Variable(tf.random_uniform((vocab_size, embed_dim), -1, 1)) embed = tf.nn.embedding_lookup(embeddings, input_data) return embed """ DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE """ tests.test_get_embed(get_embed) # ### Build RNN # You created a RNN Cell in the `get_init_cell()` function. Time to use the cell to create a RNN. # - Build the RNN using the [`tf.nn.dynamic_rnn()`](https://www.tensorflow.org/api_docs/python/tf/nn/dynamic_rnn) # - Apply the name "final_state" to the final state using [`tf.identity()`](https://www.tensorflow.org/api_docs/python/tf/identity) # # Return the outputs and final_state state in the following tuple `(Outputs, FinalState)` # In[50]: def build_rnn(cell, inputs): """ Create a RNN using a RNN Cell :param cell: RNN Cell