(self, batch_size=None, zero=True, hidden=None)
Return RNN initial state
Return RNN initial state
Return RNN initial state
def init_h(self, batch_size=None, zero=True, hidden=None):
        """Return RNN initial state"""
        if hidden is not None:
            return hidden

        if self.use_lstm:
            # (h, c)
            return (to_var(torch.zeros(self.num_layers,
                                       batch_size,
                                       self.hidden_size)),
                    to_var(torch.zeros(self.num_layers,
                                       batch_size,
                                       self.hidden_size)))
        else:
            # h
            return to_var(torch.zeros(self.num_layers,
                                      batch_size,
                                      self.hidden_size))
def init_h ( self , batch_size = None , zero = True , hidden = None ) : if hidden is not None : return hidden if self . use_lstm : # (h, c) return ( to_var ( torch . zeros ( self . num_layers , batch_size , self . hidden_size ) ) , to_var ( torch . zeros ( self . num_layers , batch_size , self . hidden_size ) ) ) else : # h return to_var ( torch . zeros ( self . num_layers , batch_size , self . hidden_size ) )