Add keepdim to RandomChannelShuffle
See original GitHub issueDescribe the bug
K.augmentation.RandomChannelShuffle
inconsistency with others kornia augmentations.
Keepdim is not in argument of the RandomChannelShuffle
class, and so always broadcast it to the batch form (eg, broadcast a torch.Size([6, 64, 64]), CHW to torch.Size([1, 6, 64, 64]) BCH*W)
Reproduction steps
>>> import torch
>>> import kornia as K
>>> image = torch.rand((6,64,64))
>>> image.shape
torch.Size([6, 64, 64])
>>> transform = K.augmentation.RandomChannelShuffle(p=0.8)
>>> transform(image).shape
torch.Size([1, 6, 64, 64])
Expected behavior
>>> import torch
>>> import kornia as K
>>> image = torch.rand((6,64,64))
>>> image.shape
torch.Size([6, 64, 64])
>>> transform = K.augmentation.RandomChannelShuffle(p=0.8, keepdim=True)
>>> transform(image).shape
torch.Size([6, 64, 64])
Environment
- PyTorch Version (e.g., 1.0): 1.10.0
- OS (e.g., Linux): Ubuntu 20.04.3 LTS (x86_64)
- How you installed PyTorch (
conda
,pip
, source): conda - Python version: 3.9.7
- CUDA/cuDNN version: 11.4.152
- GPU models and configuration: GPU 0: NVIDIA TITAN X (Pascal)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Transforms — MONAI 1.1.0 Documentation
Randomly select regions in the image, then shuffle the pixels within every region. It shuffles every channel separately. Refer to paper: Kang, Guoliang, ......
Read more >Image Augmentations - Kornia - Read the Docs
Add random blur with a box filter to an image tensor. _images/RandomBoxBlur.png. Parameters ... Shuffle the channels of a batch of multi-dimensional images....
Read more >How to randomly shuffle data and target in python?
I have a 4D array training images, whose dimensions correspond to (image_number,channels,width,height).
Read more >The Annotated Diffusion Model - Hugging Face
In this blog post, we'll take a deeper look into Denoising Diffusion Probabilistic Models (also known as DDPMs, diffusion models, ...
Read more >Pytorch Tutorial from Basic to Advance Level - Kunal Bhashkar
In this blog, I will explain about Pytorch open-source Deep Learning library with the algorithmic implementation of Deep learning concepts.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, waiting for review https://github.com/kornia/kornia/pull/1486
@julien-blanchon could you send a PR with the patch ? Not sure why some are missing @shijianjian ?