Skip to content

Fukai-Tanaka winner-take-all network

A winner-take-all network of units.

  • Class: WinnersTakeAllSystem
  • Import: from skcomplex.systems.biology.neuroscience import WinnersTakeAllSystem
  • Field: biology/neuroscience
  • Topics: neural network, competition, winner-take-all
  • References:
    • Fukai and Tanaka 1997

Use this system

The block imports the class and simulates the system with its default parameters and its tuned run settings.

from skcomplex.systems.biology.neuroscience import WinnersTakeAllSystem

trajectory = WinnersTakeAllSystem().prepare().simulate()

Parameters

The model parameters take these defaults, and set_params changes them.

Parameter Default
inputs (1.0, 1.1, 0.9, 1.05, 0.95)
beta 2.0
tau 1.0
x 0.1
solver 'auto'
backend 'auto'

Tags

The system with its default parameters has these capability tags, which solvers and analyses check.

Tag Values
Time continuous
Space none
Laws rate
Randomness deterministic
Domains real
Structure fixed

Class

The source of the class shows how it builds its components from its model parameters.

class WinnersTakeAllSystem(BaseSystem):
    """A winner-take-all network of units.

    The units have self-limited growth and mutual inhibition.

    Unit `i` follows `tau x_i' = x_i (I_i - x_i - beta sum_{j != i} x_j)`, the competitive network of Fukai and Tanaka.
    One inhibition interaction binds every unit as an element set and reads the total activity of the set, so the
    network holds one interaction whatever the number of units. When the inhibition `beta` exceeds 1, only the unit with
    the largest input stays active, at activity `I_max`. When it is below 1, several winners share the activity. The
    winners-take-all network of Gros (2015, section 10.4), with reservoir variables and clique encoding, is a different
    model. The system has the activities `unit_<i>.x`.

    Args:
        inputs:
            The input of every unit.

        beta:
            The strength of the mutual inhibition.

        tau:
            The time constant of the units.

        x:
            The initial activity of every unit.

        label:
            The label of the system, which names it when it is nested in another one.

        solver:
            The solver of the problem, or `'auto'` for the one the system chooses.

        backend:
            The backend that evaluates the compiled functions, or `'auto'` for the one the system chooses.

    Examples:
        >>> from skcomplex.systems.biology.neuroscience import WinnersTakeAllSystem
        >>> [interaction.label for interaction in WinnersTakeAllSystem((1.0, 2.0)).prepare().system_.interactions]
        ['growth_unit_0', 'growth_unit_1', 'inhibition']
    """

    field = 'biology/neuroscience'
    topics = ('neural network', 'competition', 'winner-take-all')
    references = ('Fukai and Tanaka 1997',)
    until = 40.0
    dt = 0.2

    def __init__(
        self,
        inputs: Sequence[float] = (1.0, 1.1, 0.9, 1.05, 0.95),
        *,
        beta: float = 2.0,
        tau: float = 1.0,
        x: float = 0.1,
        label: str = 'system',
        solver: BaseSolver | str = 'auto',
        backend: BaseBackend | str = 'auto',
    ) -> None:
        super().__init__(label, solver=solver, backend=backend)
        self.inputs = inputs
        self.beta = beta
        self.tau = tau
        self.x = x

    def _prepare(self, context: Sequence[Observable] | None = None) -> None:
        """Set the system of a winner-take-all network of units.

        Args:
            context:
                The observables to compile with the problem, or `None` for none.
        """
        super()._prepare(context)
        units = [
            RateUnitElement(f'unit_{index}', x=self.x, I=value, tau=self.tau) for index, value in enumerate(self.inputs)
        ]
        growth = [SaturatingGrowthInteraction(f'growth_{unit.label}', target=unit.label) for unit in units]
        inhibition = MutualInhibitionInteraction(
            'inhibition',
            units=tuple(unit.label for unit in units),
            beta=self.beta,
        )
        self.system_ = System(self.label, elements=units, interactions=[*growth, inhibition])

Components

The system uses these element and interaction classes, each with its nearest class of the core.

Elements:

Interactions:

  • SaturatingGrowthInteraction, from Interaction
  • MutualInhibitionInteraction, from Interaction
class RateUnitElement(Element):
    """Neural unit of a competitive network, whose activity grows with its input and saturates.

    A `SaturatingGrowthInteraction` grows it as `tau x' = x (I - x)`.

    Args:
        label:
            The label of the unit.

        x:
            The initial activity.

        I:
            The input.

        tau:
            The time constant.

    Examples:
        >>> from skcomplex.systems.biology.neuroscience import RateUnitElement
        >>> RateUnitElement('unit', I=1.2).I
        1.2
    """

    def __init__(
        self,
        label: str,
        *,
        x: Annotated[float, RealSet.closed_open(0, oo)] = 0.1,
        I: float = 1.0,
        tau: Annotated[float, RealSet.open(0, oo)] = 1.0,
    ) -> None:
        super().__init__(label)
        self.x = x
        self.I = I
        self.tau = tau

class SaturatingGrowthInteraction(Interaction):
    """Self-limited growth of the activity of a neural unit, `tau x' = x (I - x)`.

    The input `I` and the time constant `tau` are values of the unit, a `RateUnitElement`.

    Args:
        label:
            The label of the interaction.

        target:
            The path of the unit.

    Examples:
        >>> from skcomplex.systems.biology.neuroscience import SaturatingGrowthInteraction
        >>> SaturatingGrowthInteraction('growth', target='unit').target
        'unit'
    """

    law_classes = (RateLaw,)

    def __init__(self, label: str, *, target: Role) -> None:
        super().__init__(label)
        self.target = target

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the self-limited growth of the activity.

        Args:
            context:
                The namespace of the unit.
        """
        super()._prepare(context)
        s = context.target
        self.laws_: list[BaseLaw] = [RateLaw(s.x, s.x * (s.I - s.x) / s.tau)]

class MutualInhibitionInteraction(Interaction):
    """Inhibition of every unit by the summed activity of all the other units.

    The inhibition is `-beta x_i sum_{j != i} x_j / tau_i`.

    It is the coupling of separate units to each other, with the term `-beta x_i x_j / tau_i` of every other unit `j`.

    Args:
        label:
            The label of the interaction.

        units:
            The paths of the units.

        beta:
            The strength of the inhibition.

    Examples:
        >>> from skcomplex.systems.biology.neuroscience import MutualInhibitionInteraction
        >>> MutualInhibitionInteraction('inhibition', units=['a', 'b'], beta=2.0).beta
        2.0
    """

    law_classes = (RateLaw,)

    def __init__(
        self,
        label: str,
        *,
        units: tuple[Role, ...],
        beta: Annotated[float, RealSet.closed_open(0, oo)] = 2.0,
    ) -> None:
        super().__init__(label)
        self.units = units
        self.beta = beta

    def _prepare(self, context: SimpleNamespace) -> None:
        """Set the inhibition of every unit by the other units, term by term.

        Args:
            context:
                The namespace of the units.
        """
        super()._prepare(context)
        laws: list[BaseLaw] = []
        for unit in context.units:
            parts = [
                SR(1) * (-context.beta * unit.x * other.x / unit.tau) for other in context.units if other is not unit
            ]
            laws.append(RateLaw(unit.x, sum(parts[1:], parts[0])))
        self.laws_ = laws

Equations

The equations are those that symbolic returns for the system with its default parameters.

unit_0.x: diff(x_unit_0(t), t) == -beta_inhibition*x_unit_0(t)*x_unit_1(t)/tau_unit_0 - beta_inhibition*x_unit_0(t)*x_unit_2(t)/tau_unit_0 - beta_inhibition*x_unit_0(t)*x_unit_3(t)/tau_unit_0 - beta_inhibition*x_unit_0(t)*x_unit_4(t)/tau_unit_0 + (I_unit_0 - x_unit_0(t))*x_unit_0(t)/tau_unit_0
unit_1.x: diff(x_unit_1(t), t) == -beta_inhibition*x_unit_0(t)*x_unit_1(t)/tau_unit_1 - beta_inhibition*x_unit_1(t)*x_unit_2(t)/tau_unit_1 - beta_inhibition*x_unit_1(t)*x_unit_3(t)/tau_unit_1 - beta_inhibition*x_unit_1(t)*x_unit_4(t)/tau_unit_1 + (I_unit_1 - x_unit_1(t))*x_unit_1(t)/tau_unit_1
unit_2.x: diff(x_unit_2(t), t) == -beta_inhibition*x_unit_0(t)*x_unit_2(t)/tau_unit_2 - beta_inhibition*x_unit_1(t)*x_unit_2(t)/tau_unit_2 - beta_inhibition*x_unit_2(t)*x_unit_3(t)/tau_unit_2 - beta_inhibition*x_unit_2(t)*x_unit_4(t)/tau_unit_2 + (I_unit_2 - x_unit_2(t))*x_unit_2(t)/tau_unit_2
unit_3.x: diff(x_unit_3(t), t) == -beta_inhibition*x_unit_0(t)*x_unit_3(t)/tau_unit_3 - beta_inhibition*x_unit_1(t)*x_unit_3(t)/tau_unit_3 - beta_inhibition*x_unit_2(t)*x_unit_3(t)/tau_unit_3 - beta_inhibition*x_unit_3(t)*x_unit_4(t)/tau_unit_3 + (I_unit_3 - x_unit_3(t))*x_unit_3(t)/tau_unit_3
unit_4.x: diff(x_unit_4(t), t) == -beta_inhibition*x_unit_0(t)*x_unit_4(t)/tau_unit_4 - beta_inhibition*x_unit_1(t)*x_unit_4(t)/tau_unit_4 - beta_inhibition*x_unit_2(t)*x_unit_4(t)/tau_unit_4 - beta_inhibition*x_unit_3(t)*x_unit_4(t)/tau_unit_4 + (I_unit_4 - x_unit_4(t))*x_unit_4(t)/tau_unit_4