【发布时间】:2017-11-30 04:56:45
【问题描述】:
我无法找到在 Tensorflow 的 C++ API 中初始化变量的有效方法。我正在尝试为 MNIST 数据集制作一个基本的全连接单层神经网络。
目前,我发现正确的做法是这样的:
TF_CHECK_OK(session->Run({}, {}, {"init_all_vars_op"}, nullptr));
但是,使用它会返回以下错误:
tensorflow/cc/example/example.cc:178:71: error: no matching function for call to 'tensorflow::ClientSession::Run(<brace-enclosed initializer list>, <brace-enclosed initializer list>, <brace-enclosed initializer list>, std::nullptr_t)'.
有没有人遇到过这种情况?如果有,您是如何解决的?
编辑:我应该补充一点,如果我删除了初始化我使用的变量的任何尝试,并且只运行它会编译的会话,但它会返回:
2017-06-27 11:31:12.861244: W tensorflow/core/platform/cpu_feature_guard.cc:45] TensorFlow 库未编译为使用 SSE4.1 指令,但这些在您的计算机上可用并且可以加快 CPU 计算速度。
2017-06-27 11:31:12.862007: W tensorflow/core/platform/cpu_feature_guard.cc:45] TensorFlow 库未编译为使用 SSE4.2 指令,但这些指令在您的计算机上可用并且可以加快 CPU 计算速度。
2017-06-27 11:31:12.862433: W tensorflow/core/platform/cpu_feature_guard.cc:45] TensorFlow 库未编译为使用 AVX 指令,但这些在您的计算机上可用并且可以加快速度CPU 计算。
2017-06-27 11:31:12.866282:F tensorflow/cc/example/example.cc:180] 非 OK 状态:session->Run(feed ,{y_pred} ,&outputs) 状态:前置条件失败: 尝试使用未初始化的值权重
[[节点:MatMul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/cpu:0"](_arg_x_0_0, weights)] ]
/usr/bin/bazel 以代码 8 退出
【问题讨论】:
标签: c++ tensorflow