我是tensorflow的新手,我正在尝试按照这个入门教程.但是在"ex001.py"脚本中执行这个非常简单的代码:
import tensorflow as tf
sess = tf.Session
hello = tf.constant('Hello, TensorFlow!')
print(hello)
print(sess.run(hello))
Run Code Online (Sandbox Code Playgroud)
我得到以下输出
Tensor("Const:0",shape =(),dtype = string)Traceback(最近一次调用最后一次):文件"C:\ Users\Giuseppe\Desktop\ex001.py",第6行,打印(sess.run) (你好))TypeError:run()缺少1个必需的位置参数:'fetches'
我已经检查了tf.Session.run()语法,但看起来没错,我找不到任何有同样问题的人.
我正在运行此配置:
提前致谢
我正在尝试使用 C API 构建 Python 字典,但似乎不可能(Py_BuildValue 返回 NULL 对象)使用 PyObject* 作为值。我有这样的情况:
#include <python3.5/Python.h>
...
PyObject *myList = PyList_New(1);
PyList_SetItem(myList, 0, Py_BuildValue("i", 1));
dict = Py_BuildValue("{siso}",
"anInt", myInt,
"aList", mylist);
Run Code Online (Sandbox Code Playgroud)
我正在寻找一种适用于列表通用大小的解决方案。我在官方文档中没有找到任何有关此内容的信息,并且还用谷歌搜索了几个小时。有人可以帮助我吗?提前致谢