Swarm - Define your decentralized algorithm¶
- class manta.swarm.Swarm¶
This class defines a decentralized algorithm which must be sent to a cluster
- globals¶
Initial global values
- Type:
Dict[str, Any]
- execute() ModuleID ¶
This method must be defined by the User
- Returns:
Module ID which is the last module executed in the graph before iterating
- Return type:
Examples
>>> def execute(self): ... """ ... Generation of the task graph ... ... +--------+ +------------+ +-----------+ if has_converged ... | Worker | --> | Aggregator | --> | Scheduler | ----------------> END PROGRAM ... +--------+ +------------+ +-----------+ ... | | else ... +--<<<----------<<<----------<<<----+ ... """ ... m = self.worker() ... m = self.aggregator(m) ... return self.scheduler(m)
- set_global(tag: str, value: dict)¶
Set a global value in the swarm
Examples
>>> self.set_global( ... "hyperparameters", ... { ... "epochs": 1, ... "batch_size": 32, ... "loss": "CrossEntropyLoss", ... "loss_params": {}, ... "optimizer": "SGD", ... "optimizer_params": {"lr": 0.01, "momentum": 0.9}, ... }, ... )