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)
:param keep_prob: Dropout keep probability :return: Inference Logits """ # TODO: Implement Function infer_decoder_fn = tf.contrib.seq2seq.simple_decoder_fn_inference( output_fn, encoder_state, dec_embeddings, start_of_sequence_id, end_of_sequence_id, maximum_length, vocab_size) infer_logits, _, _ = tf.contrib.seq2seq.dynamic_rnn_decoder( dec_cell, infer_decoder_fn, scope=decoding_scope) return infer_logits """ DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE """ tests.test_decoding_layer_infer(decoding_layer_infer) # ### 构建解码层级 # # 实现 `decoding_layer()` 以创建解码器 RNN 层级。 # # - 使用 `rnn_size` 和 `num_layers` 创建解码 RNN 单元。 # - 使用 [`lambda`](https://docs.python.org/3/tutorial/controlflow.html#lambda-expressions) 创建输出函数,将输入,也就是分对数转换为类分对数(class logits)。 # - 使用 `decoding_layer_train(encoder_state, dec_cell, dec_embed_input, sequence_length, decoding_scope, output_fn, keep_prob)` 函数获取训练分对数。 # - 使用 `decoding_layer_infer(encoder_state, dec_cell, dec_embeddings, start_of_sequence_id, end_of_sequence_id, maximum_length, vocab_size, decoding_scope, output_fn, keep_prob)` 函数获取推论分对数。 # # 注意:你将需要使用 [tf.variable_scope](https://www.tensorflow.org/api_docs/python/tf/variable_scope) 在训练和推论分对数间分享变量。 # In[12]: