Ejemplo n.º 1
0
def run_tests():

    import problem_unittests as t

    t.test_decoding_layer(decoding_layer)
    t.test_decoding_layer_infer(decoding_layer_infer)
    t.test_decoding_layer_train(decoding_layer_train)
    t.test_encoding_layer(encoding_layer)
    t.test_model_inputs(model_inputs)
    t.test_process_encoding_input(process_decoder_input)
    t.test_sentence_to_seq(sentence_to_seq)
    t.test_seq2seq_model(seq2seq_model)
    t.test_text_to_ids(text_to_ids)
def run_all_tests():
    tests.test_text_to_ids(text_to_ids)

    check_tensorflow_gpu()
    tests.test_model_inputs(model_inputs)

    tests.test_process_encoding_input(process_decoder_input)

    from imp import reload
    reload(tests)
    tests.test_encoding_layer(encoding_layer)

    tests.test_decoding_layer_train(decoding_layer_train)
    tests.test_decoding_layer_infer(decoding_layer_infer)
    tests.test_decoding_layer(decoding_layer)
    tests.test_seq2seq_model(seq2seq_model)

    tests.test_sentence_to_seq(sentence_to_seq)
Ejemplo n.º 3
0
    for sentence in sentences_source:
        id_each_text = [source_vocab_to_int[word] for word in sentence.split()]
        source_id_text.append(id_each_text)
    for sentence in sentences_target:
        id_each_text = [target_vocab_to_int[word] for word in sentence.split()]
        id_each_text.append(target_vocab_to_int['<EOS>'])
        target_id_text.append(id_each_text)

    return (source_id_text, target_id_text)


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

# ### 预处理所有数据并保存
#
# 运行以下代码单元,预处理所有数据,并保存到文件中。
#

# In[4]:
"""
DON'T MODIFY ANYTHING IN THIS CELL
"""
helper.preprocess_and_save_data(source_path, target_path, text_to_ids)

# # 检查点
#
# 这是你的第一个检查点。如果你什么时候决定再回到该记事本,或需要重新启动该记事本,可以从这里继续。预处理的数据已保存到磁盘上。