How handle memory allocation error

Hello, what are your suggestions for handling blow error?
X_train = (X_train - X_mean) / X_std
MemoryError: Unable to allocate 3.56 GiB for an array with shape (106640, 1, 20, 224) and data type float64

    X_mean = np.average(X[:num_train + num_test], axis=0)
    X_std = np.std(X[:num_train + num_test], axis=0)

    X_train = (X_train - X_mean) / X_std


This is the numpy OOM error right?
Well in general, there isn’t much you can do but change your program to use less memory or buy new ram :confused:

yes sir, Can I batch input and calculate its average to reduce memory?

It seems like the error is with the temporary values.
If you switch your arrays to torch Tensor, you can do X_train.sub_(X_mean).div_(X_std).
Not sure if these exist for numpy though.