I have a piece of code to read some binary files which are written in a specific format. I want to write a tensorflow version of my read_file()
function. Is there any way to do so? I don't want to wrap my function using tf.py_function()
.
def read_file(filename):
f = open(filename, 'rb')
w = int(np.fromfile(f, np.int32, count=1))
h = int(np.fromfile(f, np.int32, count=1))
data = np.fromfile(f, np.float32, count=2 * w * h)
data = np.resize(data, (h, w, 2))
f.close()
return data