I have a google-cloud-ml job that requires loading numpy .npz files from gs bucket. I followed this example on how to load .npy files from gs, but it didn't work for me since .npz files are compressed.
Here's my code:
from StringIO import StringIO
import tensorflow as tf
import numpy as np
from tensorflow.python.lib.io import file_io
f = StringIO(file_io.read_file_to_string('gs://my-bucket/data.npz'))
data = np.load(f)
And here's the error message:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 10: invalid start byte
Apparently, encoding the data to str
is not correct, but I'm not sure how to address this.
Can some one help? Thanks!