输出图层是一个函数而不是图层

时间:2017-06-17 22:10:41

标签: python tensorflow

我收到此错误但这对其他人有效。

TypeError: output_layer must be a Layer, received: <class ‘function’> 

 output_layer = lambda x: tf.contrib.layers.fully_connected(x, 
                                                            target_vocab_size, None, scope=decoding_scope)

如果我尝试传入某些内容,我会得到一个关于非浮点数的不同错误

output_fn = (output_layer(dec_input))

TypeError: Cannot create initializer for non-floating point type.

我认为这部分可能与此有关,但我不确定它有什么问题,因为如果我将类型保持为int32然后测试通过但是如果我将其更改为float32则测试不要通过。

   start_tokens = tf.tile(tf.constant([start_of_sequence_id], dtype=tf.int32),[batch_size])
    inference_helper = tf.contrib.seq2seq.GreedyEmbeddingHelper(dec_embeddings, 
                                                                start_tokens = start_tokens,
                                                                end_token=end_of_sequence_id)

0 个答案:

没有答案