Tensorflow basic_rnn_seq2seq TypeError:预期为int32,取而代之的是-float类型的-0.1 [英] Tensorflow basic_rnn_seq2seq TypeError: Expected int32, got -0.1 of type 'float' instead

查看:531
本文介绍了Tensorflow basic_rnn_seq2seq TypeError:预期为int32,取而代之的是-float类型的-0.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在数据集上运行编码器-解码器模型.下面是示例代码:

I am trying to run the encoder-decoder model on the dataset. Below is the sample code:

self._input_data = tf.placeholder(tf.int32, [batch_size, num_steps])
self._targets = tf.placeholder(tf.int32, [batch_size, num_steps])
enc_inputs.append(self._input_data) #one batch at once
dec_inputs.append(self._targets)
model = seq2seq.basic_rnn_seq2seq(enc_inputs, dec_inputs, tf.nn.rnn_cell.BasicLSTMCell(size, state_is_tuple=True))

我收到类型不匹配的错误(如下所述).有人知道要解决这个问题吗?

I get an error of type mismatch (mentioned below). Does anyone know to solve the issue?

tensor_util.py, line 290, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
    TypeError: Expected int32, got -0.1 of type 'float' instead.

推荐答案

这是一个令人困惑的错误消息.实际的原因是,当您调用tf.get_variable()但未设置默认的初始化程序时,错误消息将令人困惑.您可以使用tf.zero_initializer()或类似的方法来抑制此错误.

This is an issue of confusing error message. The actual cause is, when you call tf.get_variable() but do not set the default initializer, the error message will be confusing. You can use a tf.zero_initializer() or something like that to suppress this error.

这篇关于Tensorflow basic_rnn_seq2seq TypeError:预期为int32,取而代之的是-float类型的-0.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆