Skip to content

Custom Operations

The core functionality of each PolyGraph Operation works using a PyTorch forward method which specifies what happens at each iteration of the simulation. This method calls the experiment() method to run experiments and generate some results, filters the nodes that eligible to send messages using filterfn() and sends and receives messages on the graph using the messagefn(), reducefn() and applyfn() methods.

FunctionMethodDescription
Experimentexperiment()Generates evidence communicated to edges
Samplersample()Draws a sample from a distribution
Trialstrials()Returns the number of trials by default
Filterfilterfn()Filters edges that are eligible to communicate evidence
Messagemessage()Creates the messages that are sent along the edges
Reducereducefn()Specifies how the evidence received from all neighbours should be aggregated by each node
Applyapplyfn()Updates the beliefs on the nodes after the messages from neighbours have been aggregated using the reduce function

To create a custom op, create a class that inherits from either the PolyGraphOp or extends and existing op such as the BalaGoyalOp and override any of the methods above to change the simulation behaviour.