From 2848c07f3b1a52bdbf7ca7e9c3b5b32ce6fb1891 Mon Sep 17 00:00:00 2001 From: Matthew Moloney Date: Sat, 28 Dec 2019 16:46:18 +0000 Subject: [PATCH] Using ByteString instead of String In TF ByteString is more of a byte buffer than valid utf8. Reading it as a String adds escape characters to non-valid utf8. Then converting it to utf16 causes separate issues. Going from ByteString to byte[] fixes both of these. --- src/TensorFlowNET.Core/Sessions/BaseSession.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TensorFlowNET.Core/Sessions/BaseSession.cs b/src/TensorFlowNET.Core/Sessions/BaseSession.cs index 0e43917b..b25e77e5 100644 --- a/src/TensorFlowNET.Core/Sessions/BaseSession.cs +++ b/src/TensorFlowNET.Core/Sessions/BaseSession.cs @@ -279,7 +279,7 @@ namespace Tensorflow break; case TF_DataType.TF_STRING: using (var reader = new CodedInputStream(new IntPtr(srcAddress).Stream(8, (long) tensor.bytesize))) - ret = NDArray.FromString(reader.ReadString()); + ret = new NDArray(reader.ReadBytes().ToByteArray()); break; case TF_DataType.TF_UINT8: ret = NDArray.Scalar(*(byte*) srcAddress); @@ -467,4 +467,4 @@ namespace Tensorflow } } } -} \ No newline at end of file +}