Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add a feature "support multi params to call forward method"?Β #3055

@invoker-bot

Description

@invoker-bot

πŸš€ Feature

I think in some cases we may need pass multi params to the model. For example,
if the model has two or more inputs or some states (LSTM, etc.).
It is easy to implement this feature. The source code is here:
https://github.com/pytorch/ignite/blob/34a707e53785cf8a524589f33a570a7516fe064e/ignite/engine/__init__.py#L107C26-L107C26, and we only need to replace

output = model(x)

with

if isinstance(x, tuple):
   output = model(*x)
else:
   output = model(x)

. Then multi params can be pass by prepare_batch, and this change is compatible with single param.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions