Skip to content

Commit 1e4e920

Browse files
committed
Protobuf.Text
1 parent 21cf2be commit 1e4e920

2 files changed

Lines changed: 10 additions & 22 deletions

File tree

src/TensorFlowNET.Core/TensorFlow.Binding.csproj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<AssemblyName>TensorFlow.NET</AssemblyName>
66
<RootNamespace>Tensorflow</RootNamespace>
77
<TargetTensorFlow>1.14.1</TargetTensorFlow>
8-
<Version>0.14.1.1</Version>
8+
<Version>0.14.2.0</Version>
99
<Authors>Haiping Chen, Meinrad Recheis, Eli Belash</Authors>
1010
<Company>SciSharp STACK</Company>
1111
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -18,12 +18,13 @@
1818
<Description>Google's TensorFlow full binding in .NET Standard.
1919
Building, training and infering deep learning models.
2020
https://tensorflownet.readthedocs.io</Description>
21-
<AssemblyVersion>0.14.1.1</AssemblyVersion>
21+
<AssemblyVersion>0.14.2.0</AssemblyVersion>
2222
<PackageReleaseNotes>Changes since v0.14.0:
2323
1: Add TransformGraphWithStringInputs.
24-
2: tf.trainer.load_graph, tf.trainer.freeze_graph</PackageReleaseNotes>
24+
2: tf.trainer.load_graph, tf.trainer.freeze_graph
25+
3: Import Protobuf.Text</PackageReleaseNotes>
2526
<LangVersion>7.3</LangVersion>
26-
<FileVersion>0.14.1.1</FileVersion>
27+
<FileVersion>0.14.2.0</FileVersion>
2728
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2829
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
2930
<SignAssembly>true</SignAssembly>
@@ -60,8 +61,9 @@ https://tensorflownet.readthedocs.io</Description>
6061
</ItemGroup>
6162

6263
<ItemGroup>
63-
<PackageReference Include="Google.Protobuf" Version="3.11.2" />
64+
<PackageReference Include="Google.Protobuf" Version="3.11.3" />
6465
<PackageReference Include="NumSharp" Version="0.30.0-alpha" />
66+
<PackageReference Include="Protobuf.Text" Version="0.4.0" />
6567
</ItemGroup>
6668

6769
<ItemGroup>

src/TensorFlowNET.Core/Training/Saving/checkpoint_management.py.cs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ limitations under the License.
2020
using System.Linq;
2121
using static Tensorflow.SaverDef.Types;
2222
using static Tensorflow.Binding;
23+
using Protobuf.Text;
2324

2425
namespace Tensorflow
2526
{
@@ -187,24 +188,9 @@ public static CheckpointState get_checkpoint_state(string checkpoint_dir, string
187188
var coord_checkpoint_filename = _GetCheckpointFilename(checkpoint_dir, latest_filename);
188189
if (File.Exists(coord_checkpoint_filename))
189190
{
190-
var file_content = File.ReadAllLines(coord_checkpoint_filename);
191+
var file_content = File.ReadAllText(coord_checkpoint_filename);
191192
// https://github.com/protocolbuffers/protobuf/issues/6654
192-
// var ckpt = CheckpointState.Parser.ParseFrom(file_content);
193-
var ckpt = new CheckpointState();
194-
var field = CheckpointState.Descriptor.FindFieldByName("model_checkpoint_path");
195-
ckpt.ModelCheckpointPath = file_content.FirstOrDefault(x => x.StartsWith(field.Name + ":")).Substring(field.Name.Length + 2);
196-
// remove first and last quote.
197-
ckpt.ModelCheckpointPath = ckpt.ModelCheckpointPath.Substring(1, ckpt.ModelCheckpointPath.Length - 2);
198-
199-
field = CheckpointState.Descriptor.FindFieldByName("all_model_checkpoint_paths");
200-
file_content.Where(x => x.StartsWith(field.Name + ":"))
201-
.ToList()
202-
.ForEach(x =>
203-
{
204-
string value = x.Substring(field.Name.Length + 2);
205-
ckpt.AllModelCheckpointPaths.Add(value.Substring(1, value.Length - 2));
206-
});
207-
193+
var ckpt = CheckpointState.Parser.ParseText(file_content);
208194
if (string.IsNullOrEmpty(ckpt.ModelCheckpointPath))
209195
throw new ValueError($"Invalid checkpoint state loaded from {checkpoint_dir}");
210196
// For relative model_checkpoint_path and all_model_checkpoint_paths,

0 commit comments

Comments
 (0)