ddf.lossnode package

Submodules

ddf.lossnode.lossnode module

class ddf.lossnode.lossnode.LossNode(node_id: UUID, communicator: Communicator, neighbors: list[Neighbor])[source]

Bases: object

add_neighbor(node_id: NodeId, loss_channel: LossChannel, cost_fn_grad: Callable[[ExchangeVector], ndarray] | None = None) None[source]

Add this node as a neighbor to the lossnode or add a new cost_fn_grad.

you will get gradients from the lossnode iff you provide a cost_fn_grad

Parameters:
  • node_id (NodeId) – the id of the (new) neighbor

  • loss_channel (LossChannel) – loss channel this cost function gradient should be associated with

  • cost_fn_grad (Callable[[ExchangeVector], np.ndarray] | None) – supply a cost function gradient as in a function that calculates the gradient.

Raises:

ValueError – in case cost_fn_grad is None and loss_channel.mode == Probe

communicator: Communicator
mode: ProcessingMode
neighbors: dict[NodeId, Neighbor]
node_id: NodeId
old_info_messages: list[InfoMessage]
run() None[source]

Main loop, do whatever a lossnode does.

step(switch_modes: bool) None[source]
class ddf.lossnode.lossnode.Neighbor(node_id: ddf.ddf.NodeId, cost_fn_gradient: dict[ddf.ant_link.loss_channel.LossChannel, collections.abc.Callable[[ddf.information.ExchangeVector], numpy.ndarray] | None])[source]

Bases: object

cost_fn_gradient: dict[LossChannel, Callable[[ExchangeVector], ndarray] | None]
node_id: NodeId

Module contents