def create_training_test_sets(self):
# training set
train_x = np.random.uniform(self.data_interval_left, self.data_interval_right, size=self.data_size)
train_x = np.sort(train_x)
train_y = self.true_f(train_x) + 3. * np.random.randn(self.data_size)
self.train_x = [train_x.reshape((train_x.shape[0], 1))]
self.train_y = [train_y.reshape((train_y.shape[0], 1))]
# test set for visualisation
self.test_x = np.arange(self.view_xrange[0], self.view_xrange[1], 0.01, dtype=np.float32)
self.test_x = np.reshape(self.test_x, (self.test_x.shape[0], 1))
self.test_y = self.true_f(self.test_x)
self.test_y = np.reshape(self.test_y, (self.test_y.shape[0], 1))
self.test_x = [self.test_x]
self.test_y = [self.test_y]
评论列表
文章目录