Skip to content

Clarify Trainer/Algorithm API #10

@doxav

Description

@doxav

Hello,

I’ve been studying the trainer implementation and want to confirm my understanding against the real code and explore possible options.

Current Behavior

  1. Agent must be a trace.model (a Module)
    The AlgorithmBase.__init__ asserts the passed agent is a Module—no plain functions or callbacks are accepted .
  2. Only single-argument __call__
    MinibatchAlgorithm.forward (and its parent classes) invoke the agent via agent(x), passing exactly one element from the dataset per call .
  3. No direct callback function support
    You cannot hand in a raw Python function or lambda to the trainer; it must be wrapped as a trace.model class (or function decorated with @trace.model) to satisfy the Module interface.

Questions

  1. Function optimization
    Must every function I want to train be bundled into a trace.model class (or decorated) before passing it to the trainer?

  2. Custom workflow steps
    If I need to bypass or extend the agent’s __call__, is the intended pattern to subclass the algorithm (e.g. MinibatchAlgorithm) and override its forward() method to call specific agent methods?

  3. Multiple arguments to the agent
    For agents that naturally take more than one input argument, is it better to:

    • Pack them into a single container (e.g. dict or tuple) and pass that as x so I am limited to 1 parameter functions,
    • Or subclass the algorithm and override forward() so it unpacks and passes multiple parameters to the agent directly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions