MCPcopy Index your code
hub / github.com/MoonInTheRiver/DiffSinger / process_output

Method process_output

utils/pl_utils.py:958–1048  ·  view source on GitHub ↗

Reduces output according to the training mode. Separates loss from logging and tqdm metrics :param output: :return:

(self, output, train=False)

Source from the content-addressed store, hash-verified

956 return new_metrics
957
958 def process_output(self, output, train=False):
959 """Reduces output according to the training mode.
960
961 Separates loss from logging and tqdm metrics
962 :param output:
963 :return:
964 """
965 # ---------------
966 # EXTRACT CALLBACK KEYS
967 # ---------------
968 # all keys not progress_bar or log are candidates for callbacks
969 callback_metrics = {}
970 for k, v in output.items():
971 if k not in ['progress_bar', 'log', 'hiddens']:
972 callback_metrics[k] = v
973
974 if train and self.use_dp:
975 num_gpus = self.num_gpus
976 callback_metrics = self.reduce_distributed_output(callback_metrics, num_gpus)
977
978 for k, v in callback_metrics.items():
979 if isinstance(v, torch.Tensor):
980 callback_metrics[k] = v.item()
981
982 # ---------------
983 # EXTRACT PROGRESS BAR KEYS
984 # ---------------
985 try:
986 progress_output = output['progress_bar']
987
988 # reduce progress metrics for tqdm when using dp
989 if train and self.use_dp:
990 num_gpus = self.num_gpus
991 progress_output = self.reduce_distributed_output(progress_output, num_gpus)
992
993 progress_bar_metrics = progress_output
994 except Exception:
995 progress_bar_metrics = {}
996
997 # ---------------
998 # EXTRACT LOGGING KEYS
999 # ---------------
1000 # extract metrics to log to experiment
1001 try:
1002 log_output = output['log']
1003
1004 # reduce progress metrics for tqdm when using dp
1005 if train and self.use_dp:
1006 num_gpus = self.num_gpus
1007 log_output = self.reduce_distributed_output(log_output, num_gpus)
1008
1009 log_metrics = log_output
1010 except Exception:
1011 log_metrics = {}
1012
1013 # ---------------
1014 # EXTRACT LOSS
1015 # ---------------

Callers 2

run_evaluationMethod · 0.95
training_forwardMethod · 0.95

Calls 2

updateMethod · 0.80

Tested by

no test coverage detected