sciai.common.Sampler
- class sciai.common.Sampler(dim, coords, func, name=None)[source]
Common data sampler.
- Parameters
- Supported Platforms:
GPU
CPU
Ascend
Examples
>>> import numpy as np >>> from sciai.common import Sampler >>> def u(x_): >>> t = x_[:, 0:1] >>> x = x_[:, 1:2] >>> return np.exp(-t) * np.sin(500 * np.pi * x) >>> ics_coords = np.array([[0.0, 0.0], [0.0, 1.0]]) >>> ics_sampler = Sampler(2, ics_coords, u, name='Initial Condition 1') >>> x_batch, y_batch = ics_sampler.sample(10) >>> print(x_batch.shape, y_batch.shape) (10, 2), (10, 1)