How to add training AUC or validation loss in MMAR or my own component?

Dears,

Thanks for your contribution. I work with clara to train my own model. When I want to evaluate whether my model is over-fitting, I can’t get any message from clara’s output. (maybe I don’t know how to do it)

And I try to add AUC tensor in aux_op component:

"aux_ops": [
    {
        "path":"auc.ComputeAUC",
            "args":{
            "tag":"AUC"
        }
    }
]

and auc.py as follow:

import tensorflow as tf
from ai4med.common.build_ctx import BuildContext
from ai4med.components.aux_ops.aux_op import AuxiliaryOperation

class ComputeAUC(AuxiliaryOperation):
    """This aux-op computes AUC by comparing similarity between model predictions and
    label data.

    Args:
         tag (str): the key name of the output tensor
         do_summary (bool): whether to aggregate result across training steps for tensorboard reporting (Default: True)
         do_print (bool): whether to aggregate result across training steps for console printing (Default: True)

    """

    def __init__(self, tag: str, do_summary=True, do_print=True):
        AuxiliaryOperation.__init__(self, do_summary, do_print)
        assert isinstance(tag, str), 'tags must be str, but got {}'.format(type(tag))
        self.tag = tag

    def get_output_tensors(self, predictions, label, build_ctx):
        """Implements the required method.

        Args:
            predictions: predictions produced by model
            label: label of the training subject
            build_ctx: build context

        Returns: dict of output tensors

        """
        auc, update_op = tf.metrics.auc(label, predictions, name="auc")
        return {self.tag: auc}

But it raise an error:

  (0) Failed precondition: Attempting to use uninitialized value AUC/true_positives
         [[node AUC/true_positives/read (defined at /opt/nvidia/medical/auc.py:35) ]]
         [[NV_MODEL_OUTPUT/_2713]]
  (1) Failed precondition: Attempting to use uninitialized value AUC/true_positives
         [[node AUC/true_positives/read (defined at /opt/nvidia/medical/auc.py:35) ]]

I know that tf.metrics.auc needs to be initialized:

auc, update_op = tf.metrics.auc(label, predictions, name="auc")
with tf.Session() as sess:
    sess.run(tf.local_variables_initializer())
    sess.run(auc)

But I don’t know where to add the initializer?
Thanks a lot!