MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / forward

Method forward

imperative/python/megengine/module/rnn.py:293–305  ·  view source on GitHub ↗
(self, input: Tensor, hx=None)

Source from the content-addressed store, hash-verified

291 return stack(h_n, axis=0)
292
293 def forward(self, input: Tensor, hx=None):
294 if self.batch_first:
295 batch_size = input.shape[0]
296 input = input.transpose((1, 0, 2)) # [seq_len, batch_size, dim]
297 else:
298 batch_size = input.shape[1]
299 if hx is None:
300 hx = self.init_hidden(batch_size)
301
302 output, h = self.apply_op(input, hx)
303 if self.batch_first:
304 output = output.transpose((1, 0, 2))
305 return output, h
306
307
308class RNN(RNNBase):

Callers

nothing calls this directly

Calls 3

init_hiddenMethod · 0.95
apply_opMethod · 0.95
transposeMethod · 0.45

Tested by

no test coverage detected