mindchemistry.e3.nn.soft_one_hot_linspace

查看源文件
mindchemistry.e3.nn.soft_one_hot_linspace(x, start, end, number, basis='smooth_finite', cutoff=True)[源代码]

投影到函数基上。返回一组 \(\{y_i(x)\}_{i=1}^N\)

\[y_i(x) = \frac{1}{Z} f_i(x)\]

其中 \(x\) 是输入,\(f_i\) 是第 i 个基函数。 \(Z\) 是一个常数(如果可能的话定义),使得:

\[\langle \sum_{i=1}^N y_i(x)^2 \rangle_x \approx 1\]

注意 bessel 基函数不能被归一化。

参数:
  • x (Tensor) - 形状为 \((...)\) 的张量。

  • start (float) - 基函数区间最小值。

  • end (float) - 基函数区间最大值。

  • number (int) - 基函数的数量 \(N\)

  • basis (str) - {'gaussian', 'cosine', 'smooth_finite', 'fourier', 'bessel'},基函数的种类。默认值:'smooth_finite'

  • cutoff (bool) - 是否要求 \(y_i(x)\) 在域 (start, end) 外取值为零。默认值:True

返回:

shape为 \((..., N)\) 的Tensor。

异常:
  • ValueError - 如果 basis 不是 {'gaussian', 'cosine', 'smooth_finite', 'fourier', 'bessel'} 之一。

支持平台:

Ascend

样例:

>>> from mindchemistry.e3.nn import soft_one_hot_linspace
>>> from mindspore import ops, Tensor
>>> x = Tensor(ops.ones((4, 6)))
>>> outputs = soft_one_hot_linspace(x, -0.5, 1.5, number=4)
>>> print(outputs.shape)
(4, 6, 4)