simrun
❭ modular_reduced_model_inference
❭ strategy
❭ RaisedCosineBasis
RaisedCosineBasis¶
-
class simrun.modular_reduced_model_inference.strategy.RaisedCosineBasis(a=
2
, c=1
, phis=None
, width=80
, reversed_=False
, backend=np
)¶ Set of raised cosine basis functions to use as a kernel for weighing synaptic activation patterns.
A raised cosine is defined as:
\[f_i(x) = \frac{1}{2} cos(a \cdot log(\tau + c) - \phi_i) + \frac{1}{2}\]where \(\tau\) is the input dimension (space or time e.g.), \(a\) is the steepness, \(c\) is the offset, and \(\phi\) is the phase. These basis functions can be superimposed using learnable weights \(x_i\) to form a single filter \(\mathbf{w}(\tau)\) over the domain \(\tau\):
\[\mathbf{w}(\tau) = \sum_{i} x_i \cdot f_i(\tau)\]And this filter can then be used to weigh the input data \(\mathbf{D}\):
\[WI(t) = \int_{t-width}^{t} \mathbf{w}(\tau) \cdot \mathbf{D}(\tau)\]Note
The notation here heavily implies that the cosine functions are defined over the time domain. However, they can equally well be used for spatial or spatiotemporal data.
- Parameters:¶
a (int) – The steepness of the raised cosine. Default is \(2\).
c (int) – The offset of the raised cosine. Default is \(1\).
phis (array) – The phases of the raised cosine. Default is
np.arange(1, 11, 0.5)
.width (int) – The width of the basis functions. Default is \(80\).
reversed_ (bool) – Whether to reverse the basis functions. Default is
False
.backend (module) – The backend to use (cupy or numpy). Default is
numpy
.
- Attributes:¶
- Methods:¶
compute
(width)Compute the vector of raised cosine basis functions \(\mathbf{f}\).
get
()Get the basis functions \(\mathbf{f}\).
Get the weighed sum \(\mathbf{w}(\tau)\) of the basis functions \(f\).
visualize
(ax, plot_kwargs)Visualize the basis functions \(\mathbf{f}\).
visualize_w
(x, ax, plot_kwargs)Visualize the superposition \(\mathbf{w}(\tau)\) of the basis functions \(\mathbf{f}\).
get_raised_cosine
(a, c, phi, t, backend)static Calculate a single raised cosine basis function \(f_i\) over the domain \(t\).