forked from 1zb/deformable-convolution-pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
33 lines (27 loc) · 714 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from modules import ConvOffset2d
num_deformable_groups = 2
N, inC, inH, inW = 1, 6, 512, 512
outC, outH, outW = 4, 512, 512
kH, kW = 3, 3
conv = nn.Conv2d(
inC,
num_deformable_groups * 2 * kH * kW,
kernel_size=(kH, kW),
stride=(1, 1),
padding=(1, 1),
bias=False).cuda()
conv_offset2d = ConvOffset2d(
inC,
outC, (kH, kW),
stride=1,
padding=1,
num_deformable_groups=num_deformable_groups).cuda()
inputs = Variable(torch.randn(N, inC, inH, inW).cuda())
offset = conv(inputs)
output = conv_offset2d(inputs, offset)
output.backward(output.data)
print(output.size())