HistoryMonitor

Send information from node to researcher during the training

Attributes

Classes

HistoryMonitor

HistoryMonitor(experiment_id, researcher_id, send)

Send information from node to researcher during the training

Parameters:

Name Type Description Default
experiment_id str

TODO

required
researcher_id str

TODO

required
client

TODO

required
Source code in fedbiomed/node/history_monitor.py
def __init__(self,
             experiment_id: str,
             researcher_id: str,
             send: Callable):
    """Simple constructor for the class.

    Args:
        experiment_id: TODO
        researcher_id: TODO
        client: TODO
    """
    self.experiment_id = experiment_id
    self.researcher_id = researcher_id
    self.send = send

Attributes

experiment_id instance-attribute
experiment_id = experiment_id
researcher_id instance-attribute
researcher_id = researcher_id
send instance-attribute
send = send

Functions

add_scalar
add_scalar(metric, iteration, epoch, total_samples, batch_samples, num_batches, num_samples_trained=None, train=False, test=False, test_on_global_updates=False, test_on_local_updates=False)

Adds a scalar value to the monitor, and sends an 'AddScalarReply' response to researcher.

Parameters:

Name Type Description Default
metric Dict[str, Union[int, float]]

recorded value

required
iteration int

current epoch iteration.

required
epoch int

current epoch

required
total_samples int

TODO

required
batch_samples int

TODO

required
num_batches int

TODO

required
num_samples_trained int

TODO

None
train bool

TODO

False
test bool

TODO

False
test_on_global_updates bool

TODO

False
test_on_local_updates bool

TODO

False
Source code in fedbiomed/node/history_monitor.py
def add_scalar(
        self,
        metric: Dict[str, Union[int, float]],
        iteration: int,
        epoch: int,
        total_samples: int,
        batch_samples: int,
        num_batches: int,
        num_samples_trained: int = None,
        train: bool = False,
        test: bool = False,
        test_on_global_updates: bool = False,
        test_on_local_updates: bool = False
) -> None:
    """Adds a scalar value to the monitor, and sends an 'AddScalarReply'
        response to researcher.

    Args:
        metric:  recorded value
        iteration: current epoch iteration.
        epoch: current epoch
        total_samples: TODO
        batch_samples: TODO
        num_batches: TODO
        num_samples_trained: TODO
        train: TODO
        test: TODO
        test_on_global_updates: TODO
        test_on_local_updates: TODO

    """
    self.send(
        FeedbackMessage(researcher_id=self.researcher_id,
                        scalar=Scalar(**{
                            'node_id': environ['NODE_ID'],
                            'experiment_id': self.experiment_id,
                            'train': train,
                            'test': test,
                            'test_on_global_updates': test_on_global_updates,
                            'test_on_local_updates': test_on_local_updates,
                            'metric': metric,
                            'iteration': iteration,
                            'epoch': epoch,
                            'num_samples_trained': num_samples_trained,
                            'total_samples': total_samples,
                            'batch_samples': batch_samples,
                            'num_batches': num_batches}
                        ))
    )