(self, bs)
return self.get_state()
Set all hidden states to zeros
Set all hidden states to zeros
Set all hidden states to zeros
def init_state(self, bs):
        ''' Set all hidden states to zeros '''
        device = next(self.parameters()).device
        if self.enable_cell:
            self.hidden_state = (torch.zeros((self.layer, bs, self.dim), device=device),
                                 torch.zeros((self.layer, bs, self.dim), device=device))
        else:
            self.hidden_state = torch.zeros(
                (self.layer, bs, self.dim), device=device)
        return self.get_state()
def init_state ( self , bs ) : device = next ( self . parameters ( ) ) . device if self . enable_cell : self . hidden_state = ( torch . zeros ( ( self . layer , bs , self . dim ) , device = device ) , torch . zeros ( ( self . layer , bs , self . dim ) , device = device ) ) else : self . hidden_state = torch . zeros ( ( self . layer , bs , self . dim ) , device = device ) return self . get_state ( )