Skip to content

Commit 1749393

Browse files
committed
run ok
1 parent b1dc68f commit 1749393

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/deep_model.cc

+5-10
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ int main(int argc, char* argv[]) {
6868
std::cout << "Session created successfully" << std::endl;
6969
}
7070

71-
// Read in the protobuf graph we exported
72-
// (The path seems to be relative to the cwd. Keep this in mind
73-
// when using `bazel run` since the cwd isn't where you call
74-
// `bazel run` but from inside a temp folder.)
71+
// Load graph protobuf
7572
GraphDef graph_def;
7673
std::string graph_path = argv[3];
7774
status = ReadBinaryProto(Env::Default(), graph_path, &graph_def);
@@ -91,7 +88,7 @@ int main(int argc, char* argv[]) {
9188
}
9289

9390
// Setup inputs and outputs
94-
// input 9:283:1 6:384:1 152:384:1
91+
// demo instance: "9:283:1 6:384:1 152:384:1"
9592
std::string libfm_data = "9:283:1 6:384:1 152:384:1";
9693
std::unordered_map<int64, std::unordered_map<int64, float> > instance;
9794
std::vector<std::string> features;
@@ -160,7 +157,7 @@ int main(int argc, char* argv[]) {
160157
// The session will initialize the outputs
161158
std::vector<tensorflow::Tensor> outputs;
162159

163-
// Run the session, evaluating our "logit" operation from the graph
160+
// Run the session, evaluating our "predict/add" operation from the graph
164161
status = session->Run(inputs, {"predict/add"}, {}, &outputs);
165162
if (!status.ok()) {
166163
std::cerr << status.ToString() << std::endl;
@@ -169,18 +166,16 @@ int main(int argc, char* argv[]) {
169166
std::cout << "Run session successfully" << std::endl;
170167
}
171168

172-
// Grab the first output (we only evaluated one graph node: "logit")
169+
// Grab the first output (we only evaluated one graph node: "predict/add")
173170
// and convert the node to a scalar representation.
174171
auto output_softmax = outputs[0].scalar<float>();
175172

176-
// (There are similar methods for vectors and matrices here:
177-
// https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/public/tensor.h)
178-
179173
// Print the results
180174
std::cout << outputs[0].DebugString() << std::endl;
181175
std::cout << "output value: " << output_softmax() << std::endl;
182176

183177
// Free any resources used by the session
184178
session->Close();
179+
185180
return 0;
186181
}

src/simple_model.cc

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33

44
using namespace tensorflow;
55

6+
/**
7+
* @brief deep model for click through rate prediction
8+
* @details [long description]
9+
*
10+
* @param argv[1] graph protobuf
11+
*
12+
* @return [description]
13+
*/
614
int main(int argc, char* argv[]) {
715
// Initialize a tensorflow session
816
Session* session;
@@ -14,10 +22,7 @@ int main(int argc, char* argv[]) {
1422
std::cout << "Session created successfully" << std::endl;
1523
}
1624

17-
// Read in the protobuf graph we exported
18-
// (The path seems to be relative to the cwd. Keep this in mind
19-
// when using `bazel run` since the cwd isn't where you call
20-
// `bazel run` but from inside a temp folder.)
25+
// Load the protobuf graph
2126
GraphDef graph_def;
2227
std::string graph_path = argv[1];
2328
status = ReadBinaryProto(Env::Default(), graph_path, &graph_def);

0 commit comments

Comments
 (0)