2017-08-12 37 views
0

我想了解一些使用Jupyter筆記本上的tensorflow框架實現的代碼,當我在運行此單元格時出現以下錯誤。我不明白這個問題,一些澄清會非常有幫助。ValueError:沒有足夠的值來解壓縮(預計3,得到2) - python/tensorflow

作爲參考,正在創建一個訓練解碼層在tensorflow。

代碼:

def decoding_layer_train(encoder_state, dec_cell, dec_embed_input, 
         target_sequence_length, max_summary_length, 
         output_layer, keep_prob): 
    """ 
    Create a decoding layer for training 
    :param encoder_state: Encoder State 
    :param dec_cell: Decoder RNN Cell 
    :param dec_embed_input: Decoder embedded input 
    :param target_sequence_length: The lengths of each sequence in the target batch 
    :param max_summary_length: The length of the longest sequence in the batch 
    :param output_layer: Function to apply the output layer 
    :param keep_prob: Dropout keep probability 
    :return: BasicDecoderOutput containing training logits and sample_id 
    """ 
    # TODO: Implement Function 

    # Helper for the training process; used by Basic Decoder to read inputs 
    training_helper = tf.contrib.seq2seq.TrainingHelper(inputs=dec_embed_input, 
                 sequence_length=target_sequence_length, 
                 time_major=False) 


    # Basic decoder 
    training_decoder = tf.contrib.seq2seq.BasicDecoder(dec_cell, 
                 training_helper, 
                 encoder_state, 
                 output_layer) 


    # Performs dynamic decoding using the decoder 
    training_decoder_output, final_state, final_sequence_lengths = tf.contrib.seq2seq.dynamic_decode(training_decoder, 
                            impute_finished=True, 
                            maximum_iterations=max_summary_length) 

    return training_decoder_output 



""" 
DON'T MODIFY ANYTHING IN THIS CELL THAT IS BELOW THIS LINE 
""" 



tests.test_decoding_layer_train(decoding_layer_train)enter code here 

錯誤消息(截圖):

Screenshot detailing the error

+0

'tf.contrib.seq2seq.dynamic_decode(...)'你期望這個返回什麼?你可以嘗試打印這個值,然後將其分配給'training_decoder_output,final_state,final_sequence_lengths' – akhilsp

+0

它需要最終輸出,最終狀態和最終序列長度,如文檔中所述:https://www.tensorflow.org/api_docs /蟒/ TF /了contrib/seq2seq/dynamic_decode – Veejay

回答

0

了它。我是用tensorflow 1.1,只是要改變這種狀況,以1.2和一切工作:)

0

我只是改變

training_decoder_output, final_state, final_sequence_lengths = tf.contrib.seq2seq.dynamic_decode(training_decoder... 

training_decoder_output, _ = tf.contrib.seq2seq.dynamic_decode(training_decoder... 

和測試的1.1過去了。

相關問題