Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python DSX中的Tensorflow:由于列表()使用预测结果失败_Python_Tensorflow_Data Science Experience - Fatal编程技术网

Python DSX中的Tensorflow:由于列表()使用预测结果失败

Python DSX中的Tensorflow:由于列表()使用预测结果失败,python,tensorflow,data-science-experience,Python,Tensorflow,Data Science Experience,在IBM Data Science体验中,我成功地使用Python中的Tensorflow构建了一个模型。它使用此模型评估测试数据。然而,当我调用它对记录进行预测时,我不能使用评估返回的结果。我遵循列表()中的描述并使用它: 我得到的错误如下: TypeErrorTraceback (most recent call last) <ipython-input-49-49a72bc2fad0> in <module>() 15 # .predict(

在IBM Data Science体验中,我成功地使用Python中的Tensorflow构建了一个模型。它使用此模型评估测试数据。然而,当我调用它对记录进行预测时,我不能使用评估返回的结果。我遵循列表()中的描述并使用它:

我得到的错误如下:

TypeErrorTraceback (most recent call last)
       <ipython-input-49-49a72bc2fad0> in <module>()
     15 # .predict() returns an iterator of dicts; convert to a list    and print
     16 # predictions
---> 17 predictions = list(p["predictions"] for p in itertools.islice(y, 6))
     18 print("Predictions: {}".format(str(predictions)))

  TypeError: 'list' object is not callable
TypeErrorTraceback(最近一次调用上次)
在()
15#.predict()返回dicts的迭代器;转换为列表并打印
16#预测
--->17预测=列表(itertools.islice(y,6)中p的p[“预测”]
18打印(“预测:{}”。格式(str(预测)))
TypeError:“列表”对象不可调用
我怎样才能解决这个问题

非常感谢


Johannes

看起来您有一个名为
list
的变量,它隐藏了标准python类型
list

非常感谢-您是对的。无意中,我在程序前面使用了list作为变量名。我改变了这个。现在我得到了一个不同的错误消息:TypeErrorTraceback(最近一次调用last)in()16#。predict()返回dicts的迭代器;转换为列表并打印17个预测--->18个预测=列表(itertools.islice(y,6)中p的p[“预测”]。。。TypeError:如果安装了pandas,则数据必须是numpy数组或pandas数据帧;得到了dict@Johannes,请为新问题打开一个新问题。谢谢-此评论帮助我解决了此问题。数据结构x_pandas_predict_数据不正确。我对它进行了如下调整,然后它开始工作:x=pd.DataFrame({k:x\u\u predict\u data[k].FEATURES中k的值})
TypeErrorTraceback (most recent call last)
       <ipython-input-49-49a72bc2fad0> in <module>()
     15 # .predict() returns an iterator of dicts; convert to a list    and print
     16 # predictions
---> 17 predictions = list(p["predictions"] for p in itertools.islice(y, 6))
     18 print("Predictions: {}".format(str(predictions)))

  TypeError: 'list' object is not callable