File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,26 @@ use the ``output_transform`` argument to transform it:
3838 metric.attach(engine, " accuracy" )
3939
4040
41+ .. warning ::
42+
43+ Please, be careful when using ``lambda `` functions to setup multiple ``output_transform `` for multiple metrics
44+
45+ .. code-block :: python
46+
47+ # Wrong
48+ # metrics_group = [Accuracy(output_transform=lambda output: output[name]) for name in names]
49+ # As lambda can not store `name` and all `output_transform` will use the last `name`
50+
51+ # A correct way. For example, using functools.partial
52+ from functools import partial
53+
54+ def ot_func (output , name ):
55+ return output[name]
56+
57+ metrics_group = [Accuracy(output_transform = partial(ot_func, name = name)) for name in names]
58+
59+ For more details, see `here <https://discuss.pytorch.org/t/evaluate-multiple-models-with-one-evaluator-results-weird-metrics/96695 >`_
60+
4161.. Note ::
4262
4363 Most of implemented metrics are adapted to distributed computations and reduce their internal states across supported
You can’t perform that action at this time.
0 commit comments