| 33 | accuracy = Accuracy() |
| 34 | |
| 35 | def eval_loader(batch_size: int) -> Iterator[List[Any]]: |
| 36 | records: List[Any] = [] |
| 37 | for i_record, record in enumerate(dataset): |
| 38 | if limit_questions is not None and i_record >= limit_questions: |
| 39 | break |
| 40 | records.append(record) |
| 41 | if len(records) >= batch_size: |
| 42 | yield records |
| 43 | records = [] |
| 44 | if records: |
| 45 | yield records |
| 46 | |
| 47 | data_len = min(len(dataset), limit_questions) if limit_questions is not None else len(dataset) |
| 48 | num_batches = int(math.ceil(data_len / eval_batch_size)) |