def __getitem__(self, idx): batch_x = [] for i in range(self.context*2+1): batch_x.append(np.zeros((self.batch_size, self.win_length, 1))) batch_y = np.zeros((self.batch_size, self.win_length, 1)) x_w = self.x[idx].reshape(len(self.x[idx])) y_w = self.y[idx].reshape(len(self.y[idx])) x_w = slicing(x_w, self.win_length, self.hop_length, windowing = self.win_input) x_w = np.pad(x_w, ((self.context, self.context),(0, 0)), 'constant', constant_values=(0)) a = [] for i in range(x_w.shape[0]): a.append(x_w[i:i+self.context*2+1]) del a[-self.context*2:] a = np.asarray(a) y_w = slicing(y_w, self.win_length, self.hop_length, windowing = self.win_output) for i in range(self.batch_size): for j in range(self.context*2+1): batch_x[j][i] = a[:,j,:][i].reshape(self.win_length,1) batch_y[i] = y_w[i].reshape(self.win_length,1) batch_x = np.swapaxes(np.asarray(batch_x), 0, 1) return batch_x, batch_y
def __getitem__(self, idx): batch_x = np.zeros((self.batch_size, self.in_length, 1)) batch_y = np.zeros((self.batch_size, self.out_length, 1)) x_w = self.x[idx].reshape(len(self.x[idx])) y_w = self.y[idx].reshape(len(self.y[idx])) x_w = slicing(x_w, self.in_length, self.hop_length, windowing=self.win) y_w = slicing(y_w, self.in_length, self.hop_length, windowing=self.win) for i in range(self.batch_size): batch_x[i] = x_w[i].reshape(self.in_length, 1) batch_y[i] = y_w[i].reshape( self.in_length, 1)[self.trim:self.trim + self.out_length] return batch_x, batch_y