feat(generator): add chebyshev nodes for Generator1D
@@ -80,6 +80,7 @@ class Generator1D(BaseGenerator):
- If set to 'equally-spaced-noisy', a normal noise will be added to the previously mentioned set of points.
- If set to 'log-spaced', the points will be fixed to a set of log-spaced points that go from t_min to t_max.
- If set to 'log-spaced-noisy', a normal noise will be added to the previously mentioned set of points,
+ - If set to 'chebyshev', the points will be chebyshev nodes of the first kind over [t_min, t_max].
defaults to 'uniform'.
:type method: str, optional
@@ -116,6 +117,11 @@ class Generator1D(BaseGenerator):
elif method == 'log-spaced-noisy':
self.examples = torch.logspace(self.t_min, self.t_max, self.size, requires_grad=True)
self.getter = lambda: torch.normal(mean=self.examples, std=self.noise_std)
+ elif method == 'chebyshev':
+ examples = torch.cos((torch.arange(size) / float(size) + 0.5) * np.pi)
+ self.examples = ((t_max + t_min) + (t_max - t_min) * examples) / 2
+ self.examples.requires_grad_(True)
+ self.getter = lambda: self.examples
else:
raise ValueError(f'Unknown method: {method}')
