sfa.algorithms.np module¶
-
class
sfa.algorithms.np.
NetworkPropagation
(abbr)[source]¶ Bases:
sfa.base.Algorithm
- A base class that defines the basic functionality of
network propagation algorithms.
- 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 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
-
W
¶
-
b
¶
-
compute
(self, b)[source]¶ - Process the assigned data
with the given basal activity, \(b\).
- Parameters
- bnumpy.ndarray
1D array of basal activity.
- Returns
- xnumpy.ndarray
1D-array object of activity at steady-state.
-
compute_batch
(self)[source]¶ Process the assigned data that contains a batch data. The result is stored in
result
member.
-
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.np.
NetworkPropagationParameterSet
[source]¶ Bases:
sfa.base.ParameterSet
An object that deals with the parameters of
sfa.algorithms.np.NetworkPropagation
base algorithm.- Attributes
alpha
floatHyperparameter, \(\alpha\) ~ (0, 1).
lim_iter
intNumber of maximum iterations in the iterative method.
apply_weight_norm
boolApply the link weight normalization.
use_rel_change
boolUse relative change for prediction.
exsol_forbidden
boolForbid the propagation computation based on the exact solution.
no_inputs
boolDo not apply the effects of inputs in a given network.
Methods
initialize
(self)Initialize the parameters with default values.
-
alpha
¶ Hyperparameter, \(\alpha\) ~ (0, 1). It controls the portion of signal flow in determining the activity. The default value is 0.5.
-
apply_weight_norm
¶ Apply the link weight normalization.
-
exsol_forbidden
¶ Forbid the propagation computation based on the exact solution. In other words, use the iterative method.
-
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.