Added support for list of tensors as metric input #2055
Conversation
|
Just one remark but it looks good ! |
|
Hi @vfdev-5 @sdesrozis , Thanks for the quick PR, looks very good to me. Thanks. |
|
Hi @Nic-Ma ,
thanks for the feedback, from ignite.engine import Engine
from ignite.metrics import Accuracy, Metric
Metric.required_output_keys = ("my_y_pred", "my_y_true")
acc = Accuracy()
print(acc.required_output_keys)
engine = Engine(lambda e, b: None)
engine.state.output = {"my_y_pred": torch.rand(4, 10), "my_y_true": torch.randint(0, 10, size=(4, ))}
acc.iteration_completed(engine)
acc.compute()
> ('my_y_pred', 'my_y_true')
> 0.125what do you think ? |
|
Hi @vfdev-5 , Thanks for your proposal and sample code! What do you think is the best way to support it? Thanks. |
|
Thanks for the details, Nic ! That's definitely requires
In this case, maybe, it is possible to introduce one function to deal with those required keys for each metric like: def from_dict(*keys):
def wrapper(output: dict):
return tuple(output[k] for k in keys)
return wrapper
acc = Accuracy(output_transform=from_dict("pred", "label"))
mean_dice = MeanDice(output_transform=from_dict("pred_inverted", "label_inverted"))what do you think ? |
|
OK, thanks for the solution. Thanks. |
|
Hi @vfdev-5 , BTW, may I know when do you plan to release ignite v0.4.5? Thanks. |
|
Hi Nic, |
|
Sounds great! |
Fixes #2013
Description:
Check list:
cc @Nic-Ma for visibility