Browse Source

ImportGraphDefFromPbFile

tags/v0.8.0
Oceania2018 6 years ago
parent
commit
1088e1fe19
3 changed files with 20 additions and 0 deletions
  1. +10
    -0
      src/TensorFlowNET.Core/Graphs/Graph.Import.cs
  2. +2
    -0
      test/TensorFlowNET.Examples/MetaGraph.cs
  3. +8
    -0
      test/TensorFlowNET.UnitTest/TrainSaverTest.cs

+ 10
- 0
src/TensorFlowNET.Core/Graphs/Graph.Import.cs View File

@@ -1,6 +1,7 @@
using Google.Protobuf; using Google.Protobuf;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;


@@ -24,5 +25,14 @@ namespace Tensorflow


return return_outputs; return return_outputs;
} }

public Status Import(string file_path)
{
var bytes = File.ReadAllBytes(file_path);
var graph_def = new Tensorflow.Buffer(bytes);
var opts = c_api.TF_NewImportGraphDefOptions();
c_api.TF_GraphImportGraphDef(_handle, graph_def, opts, Status);
return Status;
}
} }
} }

+ 2
- 0
test/TensorFlowNET.Examples/MetaGraph.cs View File

@@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Tensorflow; using Tensorflow;




+ 8
- 0
test/TensorFlowNET.UnitTest/TrainSaverTest.cs View File

@@ -1,6 +1,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text; using System.Text;
using Tensorflow; using Tensorflow;


@@ -35,6 +36,13 @@ namespace TensorFlowNET.UnitTest
}); });
} }


[TestMethod]
public void ImportGraphDefFromPbFile()
{
var g = new Graph();
var status = g.Import("mobilenet/saved_model.pb");
}

[TestMethod] [TestMethod]
public void Save1() public void Save1()
{ {


Loading…
Cancel
Save