def __init__(self, model, batchsize=<NUM_LIT:1>):
import numpy as np<EOL>self.Y = model.Y_normalized<EOL>bdict = {}<EOL>opt = np.get_printoptions()<EOL>np.set_printoptions(threshold=np.inf)<EOL>for d in range(self.Y.shape[<NUM_LIT:1>]):<EOL><INDENT>inan = np.isnan(self.Y)[:, d]<EOL>arr_str = np.array2string(inan, np.inf, <NUM_LIT:0>, True, '<STR_LIT>', formatter={'<STR_LIT:bool>':lambda x: '<STR_LIT:1>' if x else '<STR_LIT:0>'})<EOL>try:<EOL><INDENT>bdict[arr_str][<NUM_LIT:0>].append(d)<EOL><DEDENT>except:<EOL><INDENT>bdict[arr_str] = [[d], ~inan]<EOL><DEDENT><DEDENT>np.set_printoptions(**opt)<EOL>self.d = bdict.values()<EOL>
Here we want to loop over all dimensions everytime.
Thus, we can just make sure the loop goes over self.d every
time. We will try to get batches which look the same together
which speeds up calculations significantly.