mindscience.e3nn.nn.SoftOneHotLinspace
- class mindscience.e3nn.nn.SoftOneHotLinspace(start, end, number, basis='smooth_finite', cutoff=True, dtype=mindspore.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 and \(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. The resulting features are designed to be invariant under translations and rotations, making them suitable for encoding radial or scalar information in 3D geometric models.
- 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, optional) – {'gaussian', 'cosine', 'smooth_finite', 'fourier', 'bessel'}, the basis family. Default:
'smooth_finite'.cutoff (bool, optional) – whether require the \(y_i(x)\) from the outside domain of (start, end) to be vanished. Default:
True.dtype (mindspore.dtype, optional) – 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'}.
Examples
>>> from mindscience.e3nn.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)