aimhubio / aim

Aim 💫 — An easy-to-use & supercharged open-source experiment tracker.
https://aimstack.io
Apache License 2.0
5.12k stars 315 forks source link

refold graphs together #268

Closed xwjBupt closed 3 years ago

xwjBupt commented 3 years ago

Hi, can aim fold several graphs together? As in medical image segmentaion field, we ofter need to try k-fold validation. so if aim can organize the metrics of same fold together, it would be great!! Actually, right now, i use the following code under tensorboard to realize this:

    ## fold can be in [fold1,fold2,...fold_n]
    writer.add_scalar(f'%s/train_detail/Loss' %fold, train_loss, epoch)
    writer.add_scalar(f'%s/train_detail/Acc' %fold, train_acc, epoch)

    writer.add_scalar(f'%s/val_detail/Loss' % fold, val_loss, epoch)
    writer.add_scalar(f'%s/val_detail/Acc' %fold, val_acc, epoch)

so the page will be like 👍:

image

Moreover, can aim track several metrics at one time ? like < add_scalars > in tensorboard?

Huge thanks !!

gorarakelyan commented 3 years ago

Hi @xwjBupt,

To achieve the aforementioned result, you can do the following:

  1. Track metrics defining each context:

    aim.track(train_loss, name="loss", subset="train", fold=fold)
    aim.track(train_acc, name="accuracy", subset="train", fold=fold)
    aim.track(val_loss, name="loss", subset="val", fold=fold)
    aim.track(val_acc, name="accuracy", subset="val", fold=fold)
  2. Open Aim UI and search metrics by context:

    • loss, accuracy if context.fold == <fold_index>
    • loss, accuracy if context.fold in (<fold_index_1>, <fold_index_2>, ... )

More on how context works is described here

  1. To see each fold in a separate subplot, you can apply grouping by context.fold or/and by any other context key that you specified while tracking metrics.

Please try out and check if it works.

xwjBupt commented 3 years ago

yes!! it works, thank you so much!!@gorarakelyan