ecker commited on
Commit
9594a96
·
1 Parent(s): 51f6c34

Disable loss ETA for now until I fix it

Browse files
Files changed (2) hide show
  1. src/utils.py +17 -11
  2. src/webui.py +2 -2
src/utils.py CHANGED
@@ -696,7 +696,7 @@ class TrainingState():
696
 
697
  epoch = self.epoch + (self.step / self.steps)
698
  if 'lr' in self.info:
699
- self.statistics['lr'].append({'epoch': epoch, 'value': self.info['lr'], 'type': 'learning_rate'})
700
 
701
  for k in ['loss_text_ce', 'loss_mel_ce', 'loss_gpt_total']:
702
  if k not in self.info:
@@ -705,7 +705,7 @@ class TrainingState():
705
  if k == "loss_gpt_total":
706
  self.losses.append( self.statistics['loss'][-1] )
707
  else:
708
- self.statistics['loss'].append({'epoch': epoch, 'value': self.info[k], 'type': f'{"val_" if data["mode"] == "validation" else ""}{k}' })
709
 
710
  return data
711
 
@@ -728,7 +728,7 @@ class TrainingState():
728
  if len(self.losses) > 0:
729
  self.metrics['loss'].append(f'Loss: {"{:.3f}".format(self.losses[-1]["value"])}')
730
 
731
- if len(self.losses) >= 2:
732
  deriv = 0
733
  accum_length = len(self.losses)//2 # i *guess* this is fine when you think about it
734
  loss_value = self.losses[-1]["value"]
@@ -738,8 +738,8 @@ class TrainingState():
738
  d2_loss = self.losses[accum_length-i-2]["value"]
739
  dloss = (d2_loss - d1_loss)
740
 
741
- d1_step = self.losses[accum_length-i-1]["epoch"]
742
- d2_step = self.losses[accum_length-i-2]["epoch"]
743
  dstep = (d2_step - d1_step)
744
 
745
  if dstep == 0:
@@ -750,16 +750,21 @@ class TrainingState():
750
 
751
  deriv = deriv / accum_length
752
 
 
 
753
  if deriv != 0: # dloss < 0:
754
  next_milestone = None
755
  for milestone in self.loss_milestones:
756
  if loss_value > milestone:
757
  next_milestone = milestone
758
  break
 
 
759
 
760
  if next_milestone:
761
  # tfw can do simple calculus but not basic algebra in my head
762
- est_its = (next_milestone - loss_value) / deriv
 
763
  if est_its >= 0:
764
  self.metrics['loss'].append(f'Est. milestone {next_milestone} in: {int(est_its)}its')
765
  else:
@@ -769,7 +774,7 @@ class TrainingState():
769
 
770
  self.metrics['loss'] = ", ".join(self.metrics['loss'])
771
 
772
- message = f"[{self.metrics['step']}] [{self.metrics['rate']}] [ETA: {eta_hhmmss}]\n[{self.metrics['loss']}]"
773
  if self.nan_detected:
774
  message = f"[!NaN DETECTED! {self.nan_detected}] {message}"
775
 
@@ -814,6 +819,7 @@ class TrainingState():
814
  continue
815
 
816
  self.parse_metrics(data)
 
817
  # print(f"Iterations Left: {self.its - self.it} | Elapsed Time: {self.it_rates} | Time Remaining: {self.eta} | Message: {self.get_status()}")
818
 
819
  self.last_info_check_at = highest_step
@@ -959,17 +965,17 @@ def update_training_dataplot(config_path=None):
959
  print(message)
960
 
961
  if len(training_state.statistics['loss']) > 0:
962
- losses = gr.LinePlot.update(value=pd.DataFrame(training_state.statistics['loss']), x_lim=[0,training_state.epochs], x="epoch", y="value", title="Loss Metrics", color="type", tooltip=['epoch', 'value', 'type'], width=500, height=350,)
963
  if len(training_state.statistics['lr']) > 0:
964
- lrs = gr.LinePlot.update(value=pd.DataFrame(training_state.statistics['lr']), x_lim=[0,training_state.epochs], x="epoch", y="value", title="Learning Rate", color="type", tooltip=['epoch', 'value', 'type'], width=500, height=350,)
965
  del training_state
966
  training_state = None
967
  else:
968
  training_state.load_statistics()
969
  if len(training_state.statistics['loss']) > 0:
970
- losses = gr.LinePlot.update(value=pd.DataFrame(training_state.statistics['loss']), x_lim=[0,training_state.epochs], x="epoch", y="value", title="Loss Metrics", color="type", tooltip=['epoch', 'value', 'type'], width=500, height=350,)
971
  if len(training_state.statistics['lr']) > 0:
972
- lrs = gr.LinePlot.update(value=pd.DataFrame(training_state.statistics['lr']), x_lim=[0,training_state.epochs], x="epoch", y="value", title="Learning Rate", color="type", tooltip=['epoch', 'value', 'type'], width=500, height=350,)
973
 
974
  return (losses, lrs)
975
 
 
696
 
697
  epoch = self.epoch + (self.step / self.steps)
698
  if 'lr' in self.info:
699
+ self.statistics['lr'].append({'epoch': epoch, 'it': self.it, 'value': self.info['lr'], 'type': 'learning_rate'})
700
 
701
  for k in ['loss_text_ce', 'loss_mel_ce', 'loss_gpt_total']:
702
  if k not in self.info:
 
705
  if k == "loss_gpt_total":
706
  self.losses.append( self.statistics['loss'][-1] )
707
  else:
708
+ self.statistics['loss'].append({'epoch': epoch, 'it': self.it, 'value': self.info[k], 'type': f'{"val_" if data["mode"] == "validation" else ""}{k}' })
709
 
710
  return data
711
 
 
728
  if len(self.losses) > 0:
729
  self.metrics['loss'].append(f'Loss: {"{:.3f}".format(self.losses[-1]["value"])}')
730
 
731
+ if False and len(self.losses) >= 2:
732
  deriv = 0
733
  accum_length = len(self.losses)//2 # i *guess* this is fine when you think about it
734
  loss_value = self.losses[-1]["value"]
 
738
  d2_loss = self.losses[accum_length-i-2]["value"]
739
  dloss = (d2_loss - d1_loss)
740
 
741
+ d1_step = self.losses[accum_length-i-1]["it"]
742
+ d2_step = self.losses[accum_length-i-2]["it"]
743
  dstep = (d2_step - d1_step)
744
 
745
  if dstep == 0:
 
750
 
751
  deriv = deriv / accum_length
752
 
753
+ print("Deriv: ", deriv)
754
+
755
  if deriv != 0: # dloss < 0:
756
  next_milestone = None
757
  for milestone in self.loss_milestones:
758
  if loss_value > milestone:
759
  next_milestone = milestone
760
  break
761
+
762
+ print(f"Loss value: {loss_value} | Next milestone: {next_milestone} | Distance: {loss_value - next_milestone}")
763
 
764
  if next_milestone:
765
  # tfw can do simple calculus but not basic algebra in my head
766
+ est_its = (next_milestone - loss_value) / deriv * 100
767
+ print(f"Estimated: {est_its}")
768
  if est_its >= 0:
769
  self.metrics['loss'].append(f'Est. milestone {next_milestone} in: {int(est_its)}its')
770
  else:
 
774
 
775
  self.metrics['loss'] = ", ".join(self.metrics['loss'])
776
 
777
+ message = f"[{self.metrics['step']}] [{self.metrics['rate']}] [ETA: {eta_hhmmss}] [{self.metrics['loss']}]"
778
  if self.nan_detected:
779
  message = f"[!NaN DETECTED! {self.nan_detected}] {message}"
780
 
 
819
  continue
820
 
821
  self.parse_metrics(data)
822
+ print(self.get_status())
823
  # print(f"Iterations Left: {self.its - self.it} | Elapsed Time: {self.it_rates} | Time Remaining: {self.eta} | Message: {self.get_status()}")
824
 
825
  self.last_info_check_at = highest_step
 
965
  print(message)
966
 
967
  if len(training_state.statistics['loss']) > 0:
968
+ losses = gr.LinePlot.update(value=pd.DataFrame(training_state.statistics['loss']), x_lim=[0,training_state.epochs], x="epoch", y="value", title="Loss Metrics", color="type", tooltip=['epoch', 'it', 'value', 'type'], width=500, height=350,)
969
  if len(training_state.statistics['lr']) > 0:
970
+ lrs = gr.LinePlot.update(value=pd.DataFrame(training_state.statistics['lr']), x_lim=[0,training_state.epochs], x="epoch", y="value", title="Learning Rate", color="type", tooltip=['epoch', 'it', 'value', 'type'], width=500, height=350,)
971
  del training_state
972
  training_state = None
973
  else:
974
  training_state.load_statistics()
975
  if len(training_state.statistics['loss']) > 0:
976
+ losses = gr.LinePlot.update(value=pd.DataFrame(training_state.statistics['loss']), x_lim=[0,training_state.epochs], x="epoch", y="value", title="Loss Metrics", color="type", tooltip=['epoch', 'it', 'value', 'type'], width=500, height=350,)
977
  if len(training_state.statistics['lr']) > 0:
978
+ lrs = gr.LinePlot.update(value=pd.DataFrame(training_state.statistics['lr']), x_lim=[0,training_state.epochs], x="epoch", y="value", title="Learning Rate", color="type", tooltip=['epoch', 'it', 'value', 'type'], width=500, height=350,)
979
 
980
  return (losses, lrs)
981
 
src/webui.py CHANGED
@@ -510,7 +510,7 @@ def setup_gradio():
510
  y="value",
511
  title="Loss Metrics",
512
  color="type",
513
- tooltip=['epoch', 'value', 'type'],
514
  width=500,
515
  height=350,
516
  )
@@ -519,7 +519,7 @@ def setup_gradio():
519
  y="value",
520
  title="Learning Rate",
521
  color="type",
522
- tooltip=['epoch', 'value', 'type'],
523
  width=500,
524
  height=350,
525
  )
 
510
  y="value",
511
  title="Loss Metrics",
512
  color="type",
513
+ tooltip=['epoch', 'it', 'value', 'type'],
514
  width=500,
515
  height=350,
516
  )
 
519
  y="value",
520
  title="Learning Rate",
521
  color="type",
522
+ tooltip=['epoch', 'it', 'value', 'type'],
523
  width=500,
524
  height=350,
525
  )