def _prepocess_training_data(self, x, t, e, vsize, random_state): """RNNs require different preprocessing for variable length sequences""" idx = list(range(x.shape[0])) np.random.seed(random_state) np.random.shuffle(idx) x = _get_padded_features(x) t = _get_padded_targets(t) e = _get_padded_targets(e) x_train, t_train, e_train = x[idx], t[idx], e[idx] x_train = torch.from_numpy(x_train).double() t_train = torch.from_numpy(t_train).double() e_train = torch.from_numpy(e_train).double() vsize = int(vsize * x_train.shape[0]) x_val, t_val, e_val = x_train[-vsize:], t_train[-vsize:], e_train[ -vsize:] x_train = x_train[:-vsize] t_train = t_train[:-vsize] e_train = e_train[:-vsize] return (x_train, t_train, e_train, x_val, t_val, e_val)
def _prepocess_training_data(self, x, t, e, vsize, val_data, random_state): """RNNs require different preprocessing for variable length sequences""" idx = list(range(x.shape[0])) np.random.seed(random_state) np.random.shuffle(idx) x = _get_padded_features(x) x_train, t_train, e_train = x[idx], t[idx], e[idx] x_train = torch.from_numpy(x_train).double() t_train = torch.from_numpy(t_train).double() e_train = torch.from_numpy(e_train).double() if val_data is None: vsize = int(vsize*x_train.shape[0]) x_val, t_val, e_val = x_train[-vsize:], t_train[-vsize:], e_train[-vsize:] x_train = x_train[:-vsize] t_train = t_train[:-vsize] e_train = e_train[:-vsize] else: x_val, t_val, e_val = val_data x_val = _get_padded_features(x_val) t_val, _ = self.discretize(t_val, self.split, self.split_time) x_val = torch.from_numpy(x_val).double() t_val = torch.from_numpy(last(t_val)).double() e_val = torch.from_numpy(last(e_val)).double() return (x_train, t_train, e_train, x_val, t_val, e_val)
def _prepocess_test_data(self, x): return torch.from_numpy(_get_padded_features(x))
def _prepocess_test_data(self, x): data = torch.from_numpy(_get_padded_features(x)) if self.cuda: data = data.cuda() return data