compositional_graph_models/modules.py
def forward(self, h: torch.Tensor, c: torch.Tensor, dropout=None):
        """
        Computes a forward pass of Unary LSTM node.
        Args:
            h: Hidden state of the children. Dim: [batch_size, d_model]
            c: Cell state of the children. Dim: [batch_size, 1, d_model]

        Returns:
            (hidden, cell): Hidden state and cell state of parent. 
            Hidden dim: [batch_size, d_model]. Cell dim: [batch_size, 1, d_model]
        """
        c = c.squeeze(1)
        i = torch.sigmoid(self.data(h))
        f = torch.sigmoid(self.forget(h))
        o = torch.sigmoid(self.output(h))
        u = torch.tanh(self.input(h))
        if dropout is None:
            cp = i * u + f * c
        else:
            cp = i * F.dropout(u,p=dropout,training=self.training) + f * c
        hp = o * torch.tanh(cp)
        return (hp, cp.unsqueeze(1))

        Computes a forward pass of Unary LSTM node.
        Args:
            h: Hidden state of the children. Dim: [batch_size, d_model]
            c: Cell state of the children. Dim: [batch_size, 1, d_model]

        Returns:
            (hidden, cell): Hidden state and cell state of parent. 
            Hidden dim: [batch_size, d_model]. Cell dim: [batch_size, 1, d_model]
        
Computes a forward pass of Unary LSTM node.
Computes a forward pass of Unary LSTM node .
def forward(self, h: torch.Tensor, c: torch.Tensor, dropout=None):
        c = c.squeeze(1)
        i = torch.sigmoid(self.data(h))
        f = torch.sigmoid(self.forget(h))
        o = torch.sigmoid(self.output(h))
        u = torch.tanh(self.input(h))
        if dropout is None:
            cp = i * u + f * c
        else:
            cp = i * F.dropout(u,p=dropout,training=self.training) + f * c
        hp = o * torch.tanh(cp)
        return (hp, cp.unsqueeze(1))
def forward ( self , h : torch . Tensor , c : torch . Tensor , dropout = None ) : c = c . squeeze ( 1 ) i = torch . sigmoid ( self . data ( h ) ) f = torch . sigmoid ( self . forget ( h ) ) o = torch . sigmoid ( self . output ( h ) ) u = torch . tanh ( self . input ( h ) ) if dropout is None : cp = i * u + f * c else : cp = i * F . dropout ( u , p = dropout , training = self . training ) + f * c hp = o * torch . tanh ( cp ) return ( hp , cp . unsqueeze ( 1 ) )
Computes a forward pass of Unary LSTM node.
Computes a forward pass of Unary LSTM node .
"""
        Computes a forward pass of Unary LSTM node.
        Args:
            h: Hidden state of the children. Dim: [batch_size, d_model]
            c: Cell state of the children. Dim: [batch_size, 1, d_model]

        Returns:
            (hidden, cell): Hidden state and cell state of parent. 
            Hidden dim: [batch_size, d_model]. Cell dim: [batch_size, 1, d_model]
        """
(hidden, cell): Hidden state and cell state of parent.
Hidden dim: [batch_size, d_model]. Cell dim: [batch_size, 1, d_model]
( hidden cell ) : Hidden state and cell state of parent . Hidden dim : [ batch_size d_model ] . Cell dim : [ batch_size 1 d_model ]
self
h
torch.Tensor
Hidden state of the children. Dim: [batch_size, d_model]
Hidden state of the children . Dim : [ batch_size d_model ]
c
torch.Tensor
Cell state of the children. Dim: [batch_size, 1, d_model]
Cell state of the children . Dim : [ batch_size 1 d_model ]
dropout