MCPcopy Create free account
hub / github.com/drinkingcoder/FlowFormer-Official / SepConvGRU

Class SepConvGRU

core/update.py:33–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 return h
32
33class SepConvGRU(nn.Module):
34 def __init__(self, hidden_dim=128, input_dim=192+128):
35 super(SepConvGRU, self).__init__()
36 self.convz1 = nn.Conv2d(hidden_dim+input_dim, hidden_dim, (1,5), padding=(0,2))
37 self.convr1 = nn.Conv2d(hidden_dim+input_dim, hidden_dim, (1,5), padding=(0,2))
38 self.convq1 = nn.Conv2d(hidden_dim+input_dim, hidden_dim, (1,5), padding=(0,2))
39
40 self.convz2 = nn.Conv2d(hidden_dim+input_dim, hidden_dim, (5,1), padding=(2,0))
41 self.convr2 = nn.Conv2d(hidden_dim+input_dim, hidden_dim, (5,1), padding=(2,0))
42 self.convq2 = nn.Conv2d(hidden_dim+input_dim, hidden_dim, (5,1), padding=(2,0))
43
44
45 def forward(self, h, x):
46 # horizontal
47 hx = torch.cat([h, x], dim=1)
48 z = torch.sigmoid(self.convz1(hx))
49 r = torch.sigmoid(self.convr1(hx))
50 q = torch.tanh(self.convq1(torch.cat([r*h, x], dim=1)))
51 h = (1-z) * h + z * q
52
53 # vertical
54 hx = torch.cat([h, x], dim=1)
55 z = torch.sigmoid(self.convz2(hx))
56 r = torch.sigmoid(self.convr2(hx))
57 q = torch.tanh(self.convq2(torch.cat([r*h, x], dim=1)))
58 h = (1-z) * h + z * q
59
60 return h
61
62class SmallMotionEncoder(nn.Module):
63 def __init__(self, args):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected