TypeError:不允许使用`tf.tensor`作为python“ bool”



我想在我的python 3.5代码中使用TensorFlow和Teflearn库。我已经使用pip安装了两者。我有以下版本:

tensorflow 0.12.0rc0
tflearn 0.2.1
python 3.5.2
conda 4.2.13

但是,运行一些代码时,我会收到以下错误:

TypeError: Using a `tf.Tensor` as a Python `bool` is not allowed.

从我可以从GitHub上出发的问题来看,应该已经解决此问题。

我该如何修复?

编辑:这是完整的堆栈跟踪:

Traceback (most recent call last):
  File "test.py", line 35, in <module>
    agent = DQNAgent(create_mlp, n_actions, env.observation_space.shape, min_replay_size=10000, batch_size=64)
  File "agents.py", line 86, in __init__
    self.q_net = network_fn(self.s, self._n_actions)
  File "test.py", line 23, in create_mlp
    net = nn.input_data(placeholder=inputs)
  File "//anaconda/lib/python3.5/site-packages/tflearn/layers/core.py", line 55, in input_data
    if not shape and not placeholder:
  File "//anaconda/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 533, in __bool__
raise TypeError("Using a `tf.Tensor` as a Python `bool` is not allowed. "

此错误是由tflearn v0.2.1库引起的。解决此错误的方法是通过git安装最新版本:

pip install git+https://github.com/tflearn/tflearn.git

这将安装tflearn v0.2.2,此错误不再发生。

最新更新