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)
Пример #3
0
    Get input, initial state, final state, and probabilities tensor from <loaded_graph>
    :param loaded_graph: TensorFlow graph loaded from file
    :return: Tuple (InputTensor, InitialStateTensor, FinalStateTensor, ProbsTensor)
    """
    # TODO: Implement Function
    inputs = loaded_graph.get_tensor_by_name('input:0')
    init_state = loaded_graph.get_tensor_by_name('initial_state:0')
    final_state = loaded_graph.get_tensor_by_name('final_state:0')
    probs = loaded_graph.get_tensor_by_name('probs:0')
    return inputs, init_state, final_state, probs


"""
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE
"""
tests.test_get_tensors(get_tensors)

# ### Choose Word
# Implement the `pick_word()` function to select the next word using `probabilities`.

# In[62]:


def pick_word(probabilities, int_to_vocab):
    """
    Pick the next word in the generated text
    :param probabilities: Probabilites of the next word
    :param int_to_vocab: Dictionary of word ids as the keys and words as the values
    :return: String of the predicted word
    """
    # TODO: Implement Function