compositional_graph_models/modules.py
def forward(self, hl, hr, cl, cr, dropout=None): 
        """
        Computes a forward pass of Binary LSTM node.
        Args:
            hl, hr: Hidden states of the children. Dim: [batch_size, d_model]
            cl, cr: Cell states of the children. Dim: [batch_size, 1, d_model]

        Returns:
            (hp, cp): Hidden state and cell state of parent. 
            Hidden dim: [batch_size, d_model]. Cell dim: [batch_size, 1, d_model]
        """
        cl = cl.squeeze(1)
        cr = cr.squeeze(1)
        i = torch.sigmoid(self.data_left(hl) + self.data_right(hr) + self.data_bias)
        f_left = torch.sigmoid(self.forget_left_by_left(hl) + self.forget_left_by_right(hr) + self.forget_bias_left)
        f_right = torch.sigmoid(self.forget_right_by_left(hl) + self.forget_right_by_right(hr) + self.forget_bias_right)
        o = torch.sigmoid(self.output_left(hl) + self.output_right(hr) + self.output_bias)
        u = torch.tanh(self.input_left(hl) + self.input_right(hr) + self.input_bias)
        if dropout is None:
            cp = i * u + f_left * cl + f_right * cr
        else:
            cp = i * F.dropout(u,p=dropout,training=self.training) + f_left * cl + f_right * cr
        hp = o * torch.tanh(cp)
        return (hp, cp.unsqueeze(1))

        Computes a forward pass of Binary LSTM node.
        Args:
            hl, hr: Hidden states of the children. Dim: [batch_size, d_model]
            cl, cr: Cell states of the children. Dim: [batch_size, 1, d_model]

        Returns:
            (hp, cp): 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 Binary LSTM node.
Computes a forward pass of Binary LSTM node .
def forward(self, hl, hr, cl, cr, dropout=None): 
        cl = cl.squeeze(1)
        cr = cr.squeeze(1)
        i = torch.sigmoid(self.data_left(hl) + self.data_right(hr) + self.data_bias)
        f_left = torch.sigmoid(self.forget_left_by_left(hl) + self.forget_left_by_right(hr) + self.forget_bias_left)
        f_right = torch.sigmoid(self.forget_right_by_left(hl) + self.forget_right_by_right(hr) + self.forget_bias_right)
        o = torch.sigmoid(self.output_left(hl) + self.output_right(hr) + self.output_bias)
        u = torch.tanh(self.input_left(hl) + self.input_right(hr) + self.input_bias)
        if dropout is None:
            cp = i * u + f_left * cl + f_right * cr
        else:
            cp = i * F.dropout(u,p=dropout,training=self.training) + f_left * cl + f_right * cr
        hp = o * torch.tanh(cp)
        return (hp, cp.unsqueeze(1))
def forward ( self , hl , hr , cl , cr , dropout = None ) : cl = cl . squeeze ( 1 ) cr = cr . squeeze ( 1 ) i = torch . sigmoid ( self . data_left ( hl ) + self . data_right ( hr ) + self . data_bias ) f_left = torch . sigmoid ( self . forget_left_by_left ( hl ) + self . forget_left_by_right ( hr ) + self . forget_bias_left ) f_right = torch . sigmoid ( self . forget_right_by_left ( hl ) + self . forget_right_by_right ( hr ) + self . forget_bias_right ) o = torch . sigmoid ( self . output_left ( hl ) + self . output_right ( hr ) + self . output_bias ) u = torch . tanh ( self . input_left ( hl ) + self . input_right ( hr ) + self . input_bias ) if dropout is None : cp = i * u + f_left * cl + f_right * cr else : cp = i * F . dropout ( u , p = dropout , training = self . training ) + f_left * cl + f_right * cr hp = o * torch . tanh ( cp ) return ( hp , cp . unsqueeze ( 1 ) )
Computes a forward pass of Binary LSTM node.
Computes a forward pass of Binary LSTM node .
"""
        Computes a forward pass of Binary LSTM node.
        Args:
            hl, hr: Hidden states of the children. Dim: [batch_size, d_model]
            cl, cr: Cell states of the children. Dim: [batch_size, 1, d_model]

        Returns:
            (hp, cp): Hidden state and cell state of parent. 
            Hidden dim: [batch_size, d_model]. Cell dim: [batch_size, 1, d_model]
        """
(hp, cp): Hidden state and cell state of parent.
Hidden dim: [batch_size, d_model]. Cell dim: [batch_size, 1, d_model]
( hp cp ) : Hidden state and cell state of parent . Hidden dim : [ batch_size d_model ] . Cell dim : [ batch_size 1 d_model ]
self
hl
hr
cl
cr
dropout
hl, hr
Hidden states of the children. Dim: [batch_size, d_model]
Hidden states of the children . Dim : [ batch_size d_model ]
cl, cr
Cell states of the children. Dim: [batch_size, 1, d_model]
Cell states of the children . Dim : [ batch_size 1 d_model ]