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.
pull/480/head
Matthew Moloney GitHub 6 years ago
parent
commit
c12f3ad2d9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
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