MCPcopy Create free account
hub / github.com/pytorch/examples / init_hidden

Method init_hidden

word_language_model/model.py:56–62  ·  view source on GitHub ↗
(self, bsz)

Source from the content-addressed store, hash-verified

54 return F.log_softmax(decoded, dim=1), hidden
55
56 def init_hidden(self, bsz):
57 weight = next(self.parameters())
58 if self.rnn_type == 'LSTM':
59 return (weight.new_zeros(self.nlayers, bsz, self.nhid),
60 weight.new_zeros(self.nlayers, bsz, self.nhid))
61 else:
62 return weight.new_zeros(self.nlayers, bsz, self.nhid)
63
64# Temporarily leave PositionalEncoding module here. Will be moved somewhere else.
65class PositionalEncoding(nn.Module):

Callers 4

generate.pyFile · 0.80
evaluateFunction · 0.80
trainFunction · 0.80
export_onnxFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected