mirror of
https://github.com/wassname/pytorch-lightning.git
synced 2026-09-11 12:31:23 +08:00
rename variables nb -> num (#567)
* rename nb -> num * flake8 * batch_nb, epoch_nb, gpu_nb, split_nb * add _num deprecations
This commit is contained in:
committed by
William Falcon
parent
63717e8fda
commit
3a58937d8b
@@ -52,7 +52,7 @@ only the first process in DDP training logs data.
|
||||
pass
|
||||
|
||||
@rank_zero_only
|
||||
def log_metrics(self, metrics, step_num):
|
||||
def log_metrics(self, metrics, step_idx):
|
||||
# metrics is a dictionary of metric names and values
|
||||
# your code to record metrics goes here
|
||||
pass
|
||||
|
||||
@@ -21,12 +21,11 @@ class LightningLoggerBase(object):
|
||||
def __init__(self):
|
||||
self._rank = 0
|
||||
|
||||
def log_metrics(self, metrics, step_num):
|
||||
"""Record metrics
|
||||
def log_metrics(self, metrics, step_idx):
|
||||
"""Record metrics.
|
||||
|
||||
:param metric: Dictionary with metric names as keys and measured
|
||||
quanties as values
|
||||
:param step_num: Step number at which the metrics should be recorded
|
||||
:param float metric: Dictionary with metric names as keys and measured quanties as values
|
||||
:param int|None step_idx: Step number at which the metrics should be recorded
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
@@ -145,13 +145,13 @@ class CometLogger(LightningLoggerBase):
|
||||
self.experiment.log_parameters(vars(params))
|
||||
|
||||
@rank_zero_only
|
||||
def log_metrics(self, metrics, step_num=None):
|
||||
def log_metrics(self, metrics, step_idx=None):
|
||||
# Comet.ml expects metrics to be a dictionary of detached tensors on CPU
|
||||
for key, val in metrics.items():
|
||||
if is_tensor(val):
|
||||
metrics[key] = val.cpu().detach()
|
||||
|
||||
self.experiment.log_metrics(metrics, step=step_num)
|
||||
self.experiment.log_metrics(metrics, step=step_idx)
|
||||
|
||||
@rank_zero_only
|
||||
def finalize(self, status):
|
||||
@@ -169,7 +169,7 @@ class CometLogger(LightningLoggerBase):
|
||||
def version(self):
|
||||
if self.project_name and self.rest_api_key:
|
||||
# Determines the number of experiments in this project, and returns the next integer as the version number
|
||||
nb_exps = len(self.comet_api.get_experiments(self.workspace, self.project_name))
|
||||
return nb_exps + 1
|
||||
num_exps = len(self.comet_api.get_experiments(self.workspace, self.project_name))
|
||||
return num_exps + 1
|
||||
else:
|
||||
return None
|
||||
|
||||
@@ -68,7 +68,7 @@ class MLFlowLogger(LightningLoggerBase):
|
||||
self.experiment.log_param(self.run_id, k, v)
|
||||
|
||||
@rank_zero_only
|
||||
def log_metrics(self, metrics, step_num=None):
|
||||
def log_metrics(self, metrics, step_idx=None):
|
||||
timestamp_ms = int(time() * 1000)
|
||||
for k, v in metrics.items():
|
||||
if isinstance(v, str):
|
||||
@@ -76,7 +76,7 @@ class MLFlowLogger(LightningLoggerBase):
|
||||
f"Discarding metric with string value {k}={v}"
|
||||
)
|
||||
continue
|
||||
self.experiment.log_metric(self.run_id, k, v, timestamp_ms, step_num)
|
||||
self.experiment.log_metric(self.run_id, k, v, timestamp_ms, step_idx)
|
||||
|
||||
def save(self):
|
||||
pass
|
||||
|
||||
@@ -76,10 +76,10 @@ class TestTubeLogger(LightningLoggerBase):
|
||||
self.experiment.argparse(params)
|
||||
|
||||
@rank_zero_only
|
||||
def log_metrics(self, metrics, step_num=None):
|
||||
def log_metrics(self, metrics, step_idx=None):
|
||||
# TODO: HACK figure out where this is being set to true
|
||||
self.experiment.debug = self.debug
|
||||
self.experiment.log(metrics, global_step=step_num)
|
||||
self.experiment.log(metrics, global_step=step_idx)
|
||||
|
||||
@rank_zero_only
|
||||
def save(self):
|
||||
|
||||
Reference in New Issue
Block a user