How to Save Numpy Array into a File

Here is an example, we save two numpy arraies to a local file in pc and load it.

import numpy as np
import os

vec = np.array([[[1,2],[3,4]]])
label = np.array([[0,1]])

data_file = os.getcwd() + '/test.npz'
np.savez_compressed(data_file, vec=vec, label=label)
loaded = np.load(data_file)
print loaded['vec']
print loaded['label']

The result is:

[[[1 2]
  [3 4]]]
[[0 1]]