2016-12-07 1 views
0

Ich habe einen Fehler: Memory, wenn ich den Code in Python ausführen 3,5Python: Memory

unq, unq_idx = np.unique(targets, return_inverse=True) 
unq_cnt = np.bincount(unq_idx) 
cnt = np.max(unq_cnt) 
n_targets = np.empty((cnt*len(unq),) + targets.shape[1:], targets.dtype) 
n_input_patches = np.empty((cnt*len(unq),) + input_patches.shape[1:], input_patches.dtype) 
for j in range(len(unq)): 
    indices = np.random.choice(np.where(unq_idx==j)[0], cnt) 
    n_targets[j*cnt:(j+1)*cnt] = targets[indices] 
    n_input_patches[j*cnt:(j+1)*cnt] = input_patches[indices] 

und der Fehler:

n_input_patches = np.empty((cnt*len(unq),) + input_patches.shape[1:], input_patches.dtype) 
MemoryError 

Ich weiß nicht, was mit dem Code passieren. Bitte hilf mir. Vielen Dank.

Antwort