I have a Running Python code doing simple logistic regression. I create a pb file using the following statement in Python
tf.train.write_graph(sess.graph_def, '.','logistic-sigmoid-cpm-model.pb', False)
I then load it from C# using Tensorflowsharp.
var model = File.ReadAllBytes("logistic-sigmoid-cpm-model.pb");
graph.Import(model, "");
using (var session = new TFSession(graph))
{
var x = LoadCsv("dataX.csv", 1);
var y = LoadCsv("dataY1.csv", 0);
var runner = session.GetRunner();
runner.AddInput(graph["x"][0], x).AddInput(graph["y"][0], y).Fetch(graph["pred"][0]);
var output = runner.Run();
I got the following Error message
TensorFlow.TFException
HResult=0x80131500
Message=Attempting to use uninitialized value Variable
[[Node: Variable/read = Identity[T=DT_FLOAT, _class=["loc:@Variable"], _device="/job:localhost/replica:0/task:0/device:CPU:0"](Variable)]]
Source=TensorFlowSharp
StackTrace:
at TensorFlow.TFStatus.CheckMaybeRaise(TFStatus incomingStatus, Boolean last)
at TensorFlow.TFSession.Run(TFOutput[] inputs, TFTensor[] inputValues, TFOutput[] outputs, TFOperation[] targetOpers, TFBuffer runMetadata, TFBuffer runOptions, TFStatus status)
at TensorFlow.TFSession.Runner.Run(TFStatus status)
at ConsoleApp2.Program.Main(String[] args) in C:\Users\Shuo-jen\source\repos\ConsoleApp2\ConsoleApp2\Program.cs:line 35
Is the model missing something? Or I need to add some code?
User contributions licensed under CC BY-SA 3.0