Browse Source

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.
tags/v0.20
Matthew Moloney Haiping 5 years ago
parent
commit
2848c07f3b
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/TensorFlowNET.Core/Sessions/BaseSession.cs

+ 2
- 2
src/TensorFlowNET.Core/Sessions/BaseSession.cs View File

@@ -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
}
}
}
}
}

Loading…
Cancel
Save