def transform(self, Xb, yb): Xb, yb = super(RotateBatchIterator, self).transform(Xb, yb) angle = np.random.randint(-10,11) Xb_rotated = rotate(Xb, angle, axes=(2, 3), reshape=False) return Xb_rotated, yb