| 51 | |
| 52 | |
| 53 | class MyDataLoader: |
| 54 | def __init__(self, dataset, batch_size=1): |
| 55 | self.dataset = dataset |
| 56 | self.batch_size = batch_size |
| 57 | self.length = math.ceil(len(dataset) / self.batch_size) |
| 58 | |
| 59 | def __iter__(self): |
| 60 | images_list = [] |
| 61 | labels_list = [] |
| 62 | for _, (images, labels) in enumerate(self.dataset): |
| 63 | images = np.expand_dims(images, axis=0) |
| 64 | labels = np.expand_dims(labels, axis=0) |
| 65 | images_list.append(images[0]) |
| 66 | labels_list.append(labels[0]) |
| 67 | if self.batch_size == len(images_list): |
| 68 | yield (images_list, labels_list) |
| 69 | images_list = [] |
| 70 | labels_list = [] |
| 71 | |
| 72 | def __len__(self): |
| 73 | return self.length |
| 74 | |
| 75 | |
| 76 | class TestSmoothQuantTF3xNewApi(unittest.TestCase): |
no outgoing calls
searching dependent graphs…