MCPcopy Create free account
hub / github.com/BIT-MCS/DRL-eFresh / forward

Method forward

utils/spatial_att_github.py:109–125  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

107 self.prev_hidden = None
108
109 def forward(self, x):
110 if self.prev_hidden is None:
111 batch_size, _, height, width = x.size()
112 h, c = self.init_hidden(
113 batch_size, self.hidden_channels, height, width, x.device
114 )
115 else:
116 h, c = self.prev_hidden
117
118 ci = torch.sigmoid(self.Wxi(x) + self.Whi(h) + c * self.Wci)
119 cf = torch.sigmoid(self.Wxf(x) + self.Whf(h) + c * self.Wcf)
120 cc = cf * c + ci * torch.tanh(self.Wxc(x) + self.Whc(h))
121 co = torch.sigmoid(self.Wxo(x) + self.Who(h) + cc * self.Wco)
122 ch = co * torch.tanh(cc)
123
124 self.prev_hidden = ch, cc
125 return ch, cc
126
127 def reset(self):
128 self.prev_hidden = None

Callers

nothing calls this directly

Calls 1

init_hiddenMethod · 0.95

Tested by

no test coverage detected