Skip to content

Instantly share code, notes, and snippets.

@ptrblck
Created August 10, 2018 13:39
Show Gist options
  • Save ptrblck/77134cf9e93414d8bed46348696a0652 to your computer and use it in GitHub Desktop.
Save ptrblck/77134cf9e93414d8bed46348696a0652 to your computer and use it in GitHub Desktop.
import torch
import torch.nn as nn
batch_size = 10
channels = 3
h, w = 16, 16
x = torch.randn(batch_size, channels, h, w)
pool = nn.AvgPool2d((1, 2), (1, 2))
output = pool(x)
output = output.view(batch_size, channels, h//2, 2, w//2)
print(output.select(3, 1).mul_(-1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment