Skip to content Skip to sidebar Skip to footer

Unable To Load Non-arrays From An Npz File

I need to save several numpy arrays and Python objects to disk.I want to completely minimize the I/O. I don't mind if the loader or saver has to do any lifting in memory, but the

Solution 1:

Try

np.savez('test.npz', **my_data)
my_data = np.load('test.npz')
print(my_data['r1'])

NumPy saves the strings as NumPy arrays. To access the strings as Python objects, you could use the item method:

my_data = np.load('test.npz')
my_variable = my_data['annotation_info'].item()

Post a Comment for "Unable To Load Non-arrays From An Npz File"