Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTA details #24

Closed
uptodiff opened this issue Aug 11, 2020 · 2 comments
Closed

TTA details #24

uptodiff opened this issue Aug 11, 2020 · 2 comments

Comments

@uptodiff
Copy link

The effect of your proposed model and training method is really amazing. “This, combined with longer training at 45 epochs and TTA, has a bigger impact than the choices of loss functions”. It seems TTA also plays an important role. So I want to konw the detail of TTA, such as the example code or related info. Looking forward to your reply!

@MarcoForte
Copy link
Owner

Hi, I'll release the proper code for this soon. But here is the list of augmentations(and their inverses) for now.
I loop through each scale then perform each augmentation in that list and average the results.
Then I perform a weighted average of the results at the different scales.

augmentations = [(lambda x: x, lambda x: x),  (lambda x: scipy.ndimage.rotate(x,90),lambda x:scipy.ndimage.rotate(x, 270)), (lambda x: scipy.ndimage.rotate(x,180),lambda x:scipy.ndimage.rotate(x, 180)), (lambda x: scipy.ndimage.rotate(x,270),lambda x:scipy.ndimage.rotate(x, 90)),
(lambda x: x[:,::-1], lambda x: x[:,::-1]),  (lambda x: scipy.ndimage.rotate(x[:,::-1],90),lambda x:scipy.ndimage.rotate(x, 270)[:,::-1]), (lambda x: scipy.ndimage.rotate(x[:,::-1],180),lambda x:scipy.ndimage.rotate(x, 180)[:,::-1]), (lambda x: scipy.ndimage.rotate(x[:,::-1],270),lambda x:scipy.ndimage.rotate(x, 90)[:,::-1]),
(lambda x: x[::-1], lambda x: x[::-1]),  (lambda x: scipy.ndimage.rotate(x[::-1],90),lambda x:scipy.ndimage.rotate(x, 270)[::-1]), (lambda x: scipy.ndimage.rotate(x[::-1],180),lambda x:scipy.ndimage.rotate(x, 180)[::-1]), (lambda x: scipy.ndimage.rotate(x[::-1],270),lambda x:scipy.ndimage.rotate(x, 90)[::-1]),
(lambda x: x[::-1,::-1], lambda x: x[::-1,::-1]),  (lambda x: scipy.ndimage.rotate(x[::-1,::-1],90),lambda x:scipy.ndimage.rotate(x, 270)[::-1,::-1]), (lambda x: scipy.ndimage.rotate(x[::-1,::-1],180),lambda x:scipy.ndimage.rotate(x, 180)[::-1,::-1]), (lambda x: scipy.ndimage.rotate(x[::-1,::-1],270),lambda x:scipy.ndimage.rotate(x, 90)[::-1,::-1])] 


scales = [0.9, 1, 1.1]
scale_weights = np.array([0.15, 0.75, 0.15])

@uptodiff
Copy link
Author

From the code above, flip and rotate operations are the main augmentations that used in TTA. Thanks for your early reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants