c语言 int64 t占位符,为什么我会得到“您必须为dtype int64提供占位符张量输出值”?...

我正在尝试构建一个读取预先训练的模型并使用它的C++程序。我把代码from here修改了一下。 我现在拥有的是:为什么我会得到“您必须为dtype int64提供占位符张量输出值”?

int main(int argc, char* argv[]) {

// Initialize a tensorflow session

Session* session;

Status status = NewSession(SessionOptions(), &session);

if (!status.ok()) {

std::cout << status.ToString() << "\n";

return 1;

}

// Read in the protobuf graph we exported

GraphDef graph_def;

status = ReadTextProto(Env::Default(), "models/train.pbtxt", &graph_def);

if (!status.ok()) {

std::cout << status.ToString() << "\n";

return 1;

}

// Add the graph to the session

status = session->Create(graph_def);

if (!status.ok()) {

std::cout << status.ToString() << "\n";

return 1;

}

tensorflow::Tensor inputs(DT_FLOAT, TensorShape({46}));

auto inputs_flat = inputs.flat();

inputs_flat.setRandom();

// The session will initialize the outputs

std::vector<:tensor> outputs;

status = session->Run({{"input", inputs}}, {"output"}, {}, &outputs);

if (!status.ok()) {

std::cout << status.ToString() << "\n"; //

return 1;

}

// Grab the first output

// and convert the node to a scalar representation.

auto output_c = outputs[0].scalar();

// Print the results

std::cout << outputs[0].DebugString() << "\n";

std::cout << output_c() << "\n";

// Free any resources used by the session

session->Close();

return 0;

}

但是当我运行它,我得到

Invalid argument: You must feed a value for placeholder tensor 'output' with dtype int64

[[Node: output = Placeholder[_output_shapes=[[-1]], dtype=DT_INT64, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

我读models/train.pbtxt有图有14K线,所以这里我不复制它。我会把相关部分:

...................

node {

name: "input"

op: "Placeholder"

attr {

key: "_output_shapes"

value {

list {

shape {

dim {

size: -1

}

dim {

size: 46

}

}

}

}

}

attr {

key: "dtype"

value {

type: DT_FLOAT

}

}

attr {

key: "shape"

value {

shape {

}

}

}

}

node {

name: "output"

op: "Placeholder"

attr {

key: "_output_shapes"

value {

list {

shape {

dim {

size: -1

}

}

}

}

}

attr {

key: "dtype"

value {

type: DT_INT64

}

}

attr {

key: "shape"

value {

shape {

}

}

}

}

...................

所以读取的问题:这个错误信息告诉我什么?

2017-01-02

matiasg

+1

它看起来像这张张流库期待一个输出变量传递给'Run'调用的输出节点? –

+0

也许,但如何?我看到的例子像这样工作。这里还有一个:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/public –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值