(self, epoch)
| 227 | debug=config.get("runner.dataset_debug")) |
| 228 | |
| 229 | def dataloader_train_loop(self, epoch): |
| 230 | logger.info("Epoch: {}, Running DataLoader Begin.".format(epoch)) |
| 231 | batch_id = 0 |
| 232 | train_run_cost = 0.0 |
| 233 | total_examples = 0 |
| 234 | self.reader.start() |
| 235 | while True: |
| 236 | try: |
| 237 | train_start = time.time() |
| 238 | # --------------------------------------------------- # |
| 239 | fetch_var = self.exe.run( |
| 240 | program=paddle.static.default_main_program(), |
| 241 | fetch_list=[var for _, var in self.metrics.items()]) |
| 242 | # --------------------------------------------------- # |
| 243 | train_run_cost += time.time() - train_start |
| 244 | total_examples += (self.config.get("runner.train_batch_size")) |
| 245 | batch_id += 1 |
| 246 | print_step = int(config.get("runner.print_interval")) |
| 247 | if batch_id % print_step == 0: |
| 248 | metrics_string = "" |
| 249 | for var_idx, var_name in enumerate(self.metrics): |
| 250 | metrics_string += "{}: {}, ".format(var_name, |
| 251 | fetch_var[var_idx]) |
| 252 | profiler_string = "" |
| 253 | profiler_string += "avg_batch_cost: {} sec, ".format( |
| 254 | format((train_run_cost) / print_step, '.5f')) |
| 255 | profiler_string += "avg_samples: {}, ".format( |
| 256 | format(total_examples / print_step, '.5f')) |
| 257 | profiler_string += "ips: {} {}/sec ".format( |
| 258 | format(total_examples / (train_run_cost), '.5f'), |
| 259 | self.count_method) |
| 260 | logger.info("Epoch: {}, Batch: {}, {} {}".format( |
| 261 | epoch, batch_id, metrics_string, profiler_string)) |
| 262 | train_run_cost = 0.0 |
| 263 | total_examples = 0 |
| 264 | except paddle.fluid.core.EOFException: |
| 265 | self.reader.reset() |
| 266 | break |
| 267 | |
| 268 | def recdataset_train_loop(self, epoch): |
| 269 | logger.info("Epoch: {}, Running RecDatast Begin.".format(epoch)) |
no test coverage detected