Skip to content

class directly calls the __init__ methods of its base classes (Model and GaussianMixin) #296

@robot-feng

Description

@robot-feng

Description

Problem:
Currently, the Policy class directly calls the init methods of its base classes (Model and GaussianMixin) like this:

python

Model.init(self, observation_space, action_space, device)
GaussianMixin.init(self, clip_actions, clip_log_std, min_log_std, max_log_std, reduction)
This approach bypasses Python's cooperative multiple inheritance mechanism (using super()) and can lead to problems—especially if any of the base classes use super() in their own initializers. You might encounter issues such as multiple values for the same argument if the parameters are not managed properly.

Suggestion:
Modify the base classes (Model and GaussianMixin) so that they accept extra keyword arguments (using **kwargs) and call super().init(**kwargs). Then, update the Policy class to use a single super().init() call. This way, each class in the method resolution order (MRO) will only consume the parameters it needs, and the remaining arguments will be passed along properly.

What skrl version are you using?

1.4.1

What ML framework/library version are you using?

pytorch

Additional system information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions