Jupyter Utilities#1797
Conversation
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
|
/black |
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
Signed-off-by: Eric Kerfoot <[email protected]>
monai/handlers/metric_logger.py
Outdated
| def _get_loss_from_output(output): | ||
| return output["loss"].item() |
There was a problem hiding this comment.
Could be:
| def _get_loss_from_output(output): | |
| return output["loss"].item() | |
| def _get_loss_from_output(output, loss_key = "loss"): | |
| return output[loss_key].item() |
|
|
||
| def __init__( | ||
| self, | ||
| loss_transform: Callable = _get_loss_from_output, |
There was a problem hiding this comment.
Might be overkill but could be:
| loss_transform: Callable = _get_loss_from_output, | |
| loss_transform: Callable = partial(_get_loss_from_output, loss_key=MetricLoggerKeys.LOSS), |
| return fig, axes | ||
|
|
||
|
|
||
| def _get_loss_from_output(output: Union[Dict[str, torch.Tensor], torch.Tensor]) -> float: |
There was a problem hiding this comment.
Could you call the other implementation to reduce duplication?
|
Looks good. I really like plotting losses with live updates, which makes my tutorials more bloated than necessary. Would be great if that functionality could be incorporated somehow (see use of |
|
|
Signed-off-by: Eric Kerfoot <[email protected]>
| ): | ||
| """ | ||
| Plot metrics on a single graph with running averages plotted for selected keys. The values in `graphmap` | ||
| should be lists of (timepoint, value) pairs as stored in MetricLogger objects. |
There was a problem hiding this comment.
could you create a few tests for the plotting method and MetricLogger? came across this util not sure how reliable it is https://github.com/matplotlib/matplotlib/blob/6fe34e72d2b7daf8586a08a8611cc73b3c0ad60c/lib/matplotlib/testing/decorators.py#L393
There was a problem hiding this comment.
I forgot to request changes for unit tests, could you please have a follow-up PR, thank you! @ericspod
|
without tests it's difficult for the other maintainers to understand the intended behaviour and ensure the quality... |
|
followup testing addressed by #1826 |
Description
This includes some utilities to help use MONAI in Jupyter. I will have an example notebook shortly for the tutorials repo. One issue is that the type checking was difficult to fully include and make work with Matplotlib so some values are untyped, and
optional_importcause circular dependency issues in the utility file.Status
Ready
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests.make htmlcommand in thedocs/folder.