sfa.algorithms.sp module¶
-
class
sfa.algorithms.sp.
SignalPropagation
(abbr)[source]¶ Bases:
sfa.algorithms.np.NetworkPropagation
- Attributes
- W
abbr
Abbreviation or symbol representing this item.
- b
data
The object of
sfa.base.Data
.name
Full name or description of this item.
params
The object of
sfa.base.ParameterSet
.result
The object of
sfa.base.Result
.
Methods
apply_inputs
(self, inds, vals)compute
(self, b)Process the assigned data
compute_batch
(self)Process the assigned data that contains a batch data.
initialize_basal_activity
(self)Initialize the basal activity, \(b\).
initialize_network
(self)Initialize the data structures related to network.
prepare_exact_solution
(self)Prepare to get the matrix for the exact solution:
Prepare to get the solution from the iterative method.
propagate_exact
(self, b)Obtain the activity at steady-state based on the exact solution of network propagation.
propagate_iterative
(self, W, xi, b[, a, …])Compute network propagation based on the iterative method.
apply_perturbations
copy
initialize
-
prepare_exact_solution
(self)[source]¶ Prepare to get the matrix for the exact solution:
When $t -> inf$, both $x(t+1)$ and $x(t)$ converges to the stationary state.
- Then, s = aW*s + (1-a)b
(I-aW)*s = (1-a)b s = (I-aW)^-1 * (1-a)b s = M*b, where M is (1-a)(I-aW)^-1.
This method is to get the matrix, M for preparing the exact solution
-
propagate_exact
(self, b)[source]¶ Obtain the activity at steady-state based on the exact solution of network propagation.
- Parameters
- bnumpy.ndarray
1D array of basal activity.
- Returns
- xnumpy.ndarray
The exact solution of the activity at steady-state in 1D array.
-
propagate_iterative
(self, W, xi, b, a=0.5, lim_iter=1000, tol=1e-05, get_trj=False)[source]¶ Compute network propagation based on the iterative method. This method should be used if we want to obtain the trajectory.
- Parameters
- W: numpy.ndarray
2D array for weight matrix.
- xi: numpy.ndarray
1D array for initial state.
- b: numpy.ndarray
1D array for basal activity.
- a: real number, optional
Hyperparameter, \(\alpha\), ~ (0, 1). The default value is 0.5.
- lim_iter: int, optional
Number of maximum iterations in the iterative method. Computation terminates when the iteration reaches
lim_iter
. The default value is 1000.- tol: float, optional
Tolerance for terminating iteration. Iteration continues, if Frobenius norm of \(x(t+1)-x(t)\) is greater than
tol
. The default value is 1e-5.- get_trj: bool, optional
Determine whether the trajectory of the state is returned. If get_trj is true, the trajectory is returned.
- Returns
- xnumpy.ndarray
1D array of the activity after the computation.
- trjnumpy.ndarray
2D array where the row represents a state of the activity.
-
class
sfa.algorithms.sp.
SignalPropagationParameterSet
[source]¶ Bases:
sfa.algorithms.np.NetworkPropagationParameterSet
- Attributes
alpha
Hyperparameter, \(\alpha\) ~ (0, 1).
apply_weight_norm
Apply the link weight normalization.
exsol_forbidden
Forbid the propagation computation based on the exact solution.
lim_iter
Number of maximum iterations in the iterative method.
no_inputs
Do not apply the effects of inputs in a given network.
use_rel_change
Use relative change for prediction.
Methods
initialize
(self)Initialize the parameters with default values.