Skip to content

Method name conflict: BasePyTorchClassifier.train overlaps with nn.Module.train semantics #185

Description

@fabiobrau

In base_pytorch_nn.py, BasePyTorchClassifier defines a train(dataloader) method.

This overlaps semantically with torch.nn.Module.train(), which is normally used to switch the module to training mode (optionally with a boolean flag), not to run a full training loop.

Because of this name overlap, the API can be confusing and may lead to unintended usage when users expect PyTorch-native behavior from .train().

Current behavior

  • BasePyTorchClassifier.train(dataloader) triggers trainer-based fitting.
  • The wrapped model’s native mode switch method (model.train()) is a different concept.

Why this is a problem

  • Naming collision with a very common PyTorch API.
  • Higher risk of misuse and reduced readability.

Suggested fix

  • Rename BasePyTorchClassifier.train(...) to something unambiguous like fit(...) or fit_model(...).
  • Keep backward compatibility with a deprecation warning on train(...) for one release cycle.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

refactoringImprovements that don't add or modify functionalities.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions