Mediate (or Bend the Rules)
The dp library can be very rigid in how the interactions between different objects are regulated (e.g. how DataSet, Propagator, Module and Criterion all work together like clockwork). Yet when doing research and development in the field of deep learning, we often need to build models that require non-standard interactions. While the library cannot provide rigid interaction patterns for every research use case, it provides different flexible alternatives. In this section we examine the Mediator singleton and its supporting classes that implement the Publish–subscribe pattern:
- Mediator : singleton that implements listen-notify pattern;
- Channel : can be published and subscribed to;
- Subscriber : encapsulates a listening object and callback method;
A singleton referenced by most objects directly or indirectly encapsulated by an Experiment.
Used internally by Mediator. Can be published and subscribed to.
Used internally by Mediator. Holds a listening object (or subscriber) which will be called
back via its
func_name method name. Since no functions are being
pointed to directly, the object can be serialized.