Channel_shuffle
Source:R/gen-namespace-docs.R
, R/gen-namespace-examples.R
, R/gen-namespace.R
torch_channel_shuffle.Rd
Channel_shuffle
Divide the channels in a tensor of shape
math:(*, C , H, W)
:
Divide the channels in a tensor of shape \((*, C , H, W)\) into g groups and rearrange them as \((*, C \frac g, g, H, W)\), while keeping the original tensor shape.
Examples
if (torch_is_installed()) {
input <- torch_randn(c(1, 4, 2, 2))
print(input)
output <- torch_channel_shuffle(input, 2)
print(output)
}
#> torch_tensor
#> (1,1,.,.) =
#> -0.2427 0.5082
#> 0.3634 -0.9331
#>
#> (1,2,.,.) =
#> -1.8722 -0.8069
#> -0.8205 1.1755
#>
#> (1,3,.,.) =
#> 0.5908 0.7549
#> -0.2153 0.2705
#>
#> (1,4,.,.) =
#> 0.3802 -2.4265
#> 0.5164 -0.4698
#> [ CPUFloatType{1,4,2,2} ]
#> torch_tensor
#> (1,1,.,.) =
#> -0.2427 0.5082
#> 0.3634 -0.9331
#>
#> (1,2,.,.) =
#> 0.5908 0.7549
#> -0.2153 0.2705
#>
#> (1,3,.,.) =
#> -1.8722 -0.8069
#> -0.8205 1.1755
#>
#> (1,4,.,.) =
#> 0.3802 -2.4265
#> 0.5164 -0.4698
#> [ CPUFloatType{1,4,2,2} ]