mindchemistry.e3.nn.SoftOneHotLinspace
- class mindchemistry.e3.nn.SoftOneHotLinspace(start, end, number, basis='smooth_finite', cutoff=True, dtype=float32)[source]
Projection on a basis of functions. Returns a set of \(\{y_i(x)\}_{i=1}^N\),
\[y_i(x) = \frac{1}{Z} f_i(x)\]where \(x\) is the input and \(f_i\) is the ith basis function. \(Z\) is a constant defined (if possible) such that,
\[\langle \sum_{i=1}^N y_i(x)^2 \rangle_x \approx 1\]Note that bessel basis cannot be normalized.
- Parameters
start (float) – minimum value span by the basis.
end (float) – maximum value span by the basis.
number (int) – number of basis functions \(N\).
basis (str) – {'gaussian', 'cosine', 'smooth_finite', 'fourier', 'bessel'}, the basis family. Default:
'smooth_finite'
.cutoff (bool) – whether require the \(y_i(x)\) from the outside domain of (start, end) to be vanished. Default:
True
.dtype (mindspore.dtype) – The type of input tensor. Default:
mindspore.float32
.
- Inputs:
x (Tensor) - The shape of Tensor is \((...)\).
- Outputs:
output (Tensor) - The shape of Tensor is \((..., N)\).
- Raises
ValueError – If basis is not in {'gaussian', 'cosine', 'smooth_finite', 'fourier', 'bessel'}.
- Supported Platforms:
Ascend
Examples
>>> from mindchemistry.e3.nn import SoftOneHotLinspace >>> from mindspore import ops, Tensor >>> soft_one_hot_linspace = SoftOneHotLinspace(-0.5, 1.5, number=4) >>> x = Tensor(ops.ones((4, 6))) >>> outputs = soft_one_hot_linspace(x) >>> print(outputs.shape) (4, 6, 4)