MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / get_data

Function get_data

examples/SpatialTransformer/mnist-addition.py:182–201  ·  view source on GitHub ↗
(isTrain)

Source from the content-addressed store, hash-verified

180
181
182def 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
204def view_warp(modelpath):

Callers 2

view_warpFunction · 0.70
get_configFunction · 0.70

Calls 4

JoinDataClass · 0.85
MapDataClass · 0.85
BatchDataClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…