MCPcopy Index your code
hub / github.com/davda54/sam / flush

Method flush

example/utility/log.py:34–52  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

32 self._eval_step(loss, accuracy)
33
34 def flush(self) -> None:
35 if self.is_train:
36 loss = self.epoch_state["loss"] / self.epoch_state["steps"]
37 accuracy = self.epoch_state["accuracy"] / self.epoch_state["steps"]
38
39 print(
40 f"\r┃{self.epoch:12d} ┃{loss:12.4f} │{100*accuracy:10.2f} % ┃{self.learning_rate:12.3e} │{self._time():>12} ┃",
41 end="",
42 flush=True,
43 )
44
45 else:
46 loss = self.epoch_state["loss"] / self.epoch_state["steps"]
47 accuracy = self.epoch_state["accuracy"] / self.epoch_state["steps"]
48
49 print(f"{loss:12.4f} │{100*accuracy:10.2f} % ┃", flush=True)
50
51 if accuracy > self.best_accuracy:
52 self.best_accuracy = accuracy
53
54 def _train_step(self, model, loss, accuracy, learning_rate: float) -> None:
55 self.learning_rate = learning_rate

Callers 3

trainMethod · 0.95
evalMethod · 0.95
train.pyFile · 0.80

Calls 1

_timeMethod · 0.95

Tested by

no test coverage detected