Skip to content

cannot import name 'Metric' from partially initialized module 'ignite.metrics' #3319

@xiuguangli

Description

@xiuguangli

from ignite.metrics import Metric
ImportError: cannot import name 'Metric' from partially initialized module 'ignite.metrics' (most likely due to a circular import)

/ignite/metrics/init.py)

I solved that by
def create_supervised_evaluator(
model: torch.nn.Module,
# metrics: Optional[Dict[str, Metric]] = None, #############this is the problem,i modify i by delete Optional[Dict[str, Metric]].
metrics = None,
device: Optional[Union[str, torch.device]] = None,
non_blocking: bool = False,
prepare_batch: Callable = _prepare_batch,
model_transform: Callable[[Any], Any] = lambda output: output,
output_transform: Callable[[Any, Any, Any], Any] = lambda x, y, y_pred: (y_pred, y),
amp_mode: Optional[str] = None,
model_fn: Callable[[torch.nn.Module, Any], Any] = lambda model, x: model(x),
) -> Engine:

Does have other ways to solve that?I dont want to modify source file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions