layers.basis.Phi
layers.basis.Phi(
self
basis_size
activation
key=None
w_dist='uniform'
w_scale=1.0
b_dist='linspace'
b_scale=1.0
imode=0
)
Phi (1-Basis) layer class
This class has two vector data \(\boldsymbol{w}^{(p)}\) and \(\boldsymbol{b}^{(p)}\) which are the weight and bias, respectively.
The forward transformation is given by
\[ D @ \phi^{(p)}_{\rho_p} = \phi(w^{(p)}_{\rho_p} (D @ \boldsymbol{q}[p]) + b^{(p)}_{\rho_p}) \]
where \(\phi\) is the activation function, \(D\) is the size of the batch, \(\boldsymbol{q}[p]\) is the hidden coordinates of the p-th mode, \(\rho_p = 1, 2, \cdots, N\) is the index of the basis, \(w^{(p)}_{\rho_p}\) is the weight, and \(b^{(p)}_{\rho_p}\) is the bias.
Note
\(\phi^{(p)}_{0}\) is fixed to 1.
Parameters
Name | Type | Description | Default |
---|---|---|---|
basis_size | int | number of basis N | required |
activation | str | activation function | required |
key | Array | random key. Defaults to None. | None |
w_dist | str | distribution of the weight. Available distributions are “uniform”, “normal”, “ones”. | 'uniform' |
w_scale | float | scale of the weight. Defaults to 1.0. | 1.0 |
b_dist | str | distribution of the bias. | 'linspace' |
b_scale | float | scale of the bias. Defaults to 1.0. Available distributions are “uniform”, “normal”, “linspace”. | 1.0 |
imode | int | index of the mode p | 0 |
Methods
Name | Description |
---|---|
forward | Forward transformation |
partial | Partial derivative of the basis |
forward
Forward transformation
Parameters
Name | Type | Description | Default |
---|---|---|---|
q | Array | hidden coordinates of the p-th mode with shape (D,) where D is the size of the batch. | required |
Returns
Name | Type | Description |
---|---|---|
Array | Array | basis with shape (D, N) where D is the size of the batch and N is the basis size. |
partial
Partial derivative of the basis with respect to the q-th hidden coordinate.
Parameters
Name | Type | Description | Default |
---|---|---|---|
q | Array | hidden coordinates with shape (D,) where D is the size of the batch. | required |
q0 | Array | hidden coordinates with shape (N-1,) where N is the basis size. | required |
Returns
Name | Type | Description |
---|---|---|
Array | Array | ∂φ(wq + b) / ∂q with shape (D, N) where D is the size of the batch and N is the basis size. |