(isTrain)
| 180 | |
| 181 | |
| 182 | def get_data(isTrain): |
| 183 | ds = dataset.Mnist('train' if isTrain else 'test') |
| 184 | # create augmentation for both training and testing |
| 185 | augs = [ |
| 186 | imgaug.MapImage(lambda x: x * 255.0), |
| 187 | imgaug.RandomResize((0.7, 1.2), (0.7, 1.2)), |
| 188 | imgaug.RotationAndCropValid(45), |
| 189 | imgaug.RandomPaste((IMAGE_SIZE, IMAGE_SIZE)), |
| 190 | imgaug.SaltPepperNoise(white_prob=0.01, black_prob=0.01) |
| 191 | ] |
| 192 | ds = AugmentImageComponent(ds, augs) |
| 193 | |
| 194 | ds = JoinData([ds, ds]) |
| 195 | # stack the two digits into two channels, and label it with the sum |
| 196 | |
| 197 | def mapper(dp): |
| 198 | return [np.stack([dp[0], dp[2]], axis=2), dp[1] + dp[3]] |
| 199 | ds = MapData(ds, dp) |
| 200 | ds = BatchData(ds, 128) |
| 201 | return ds |
| 202 | |
| 203 | |
| 204 | def view_warp(modelpath): |
no test coverage detected
searching dependent graphs…