| 82 | return loss |
| 83 | |
| 84 | def train(self, epochs, batch_size, num_batches): |
| 85 | data_generator_iter = gen_batches(num_batches, batch_size, self.units) |
| 86 | sample_x, sample_y = next(data_generator_iter) |
| 87 | self.train_on_batch(sample_x, sample_y) |
| 88 | self._training = True |
| 89 | progress_bar = tqdm(range(epochs), desc="Epochs") |
| 90 | for epoch in progress_bar: |
| 91 | for batch_x, batch_y in data_generator_iter: |
| 92 | loss = self.train_on_batch(batch_x, batch_y) |
| 93 | progress_bar.update(1) |
| 94 | progress_bar.set_postfix({"loss": f"{loss.numpy():.3f}"}) |
| 95 | |
| 96 | |
| 97 | def _run_benchmark(model): |