日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時間:2025/4/5 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言 int64 t占位符,为什么我会得到“您必须为dtype int64提供占位符张量输出值”?... 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我正在嘗試構(gòu)建一個讀取預先訓練的模型并使用它的C++程序。我把代碼from here修改了一下。 我現(xiàn)在擁有的是:為什么我會得到“您必須為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'調(diào)用的輸出節(jié)點? –

+0

也許,但如何?我看到的例子像這樣工作。這里還有一個:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/core/public –

總結(jié)

以上是生活随笔為你收集整理的c语言 int64 t占位符,为什么我会得到“您必须为dtype int64提供占位符张量输出值”?...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。