baseline/DCRNN.py
def forward(self, G: torch.Tensor, x: torch.Tensor):
        '''
        Batch-wise graph convolution operation on given n support adj matrices
        :param G: support adj matrices - torch.Tensor (K, n_nodes, n_nodes)
        :param x: graph feature/signal - torch.Tensor (batch_size, n_nodes, input_dim)
        :return: hidden representation - torch.Tensor (batch_size, n_nodes, hidden_dim)
        '''
        assert self.K == G.shape[0]

        support_list = list()
        for k in range(self.K):
            support = torch.einsum('ij,bjp->bip', [G[k, :, :], x])
            support_list.append(support)
        support_cat = torch.cat(support_list, dim=-1)

        output = torch.einsum('bip,pq->biq', [support_cat, self.W])
        if self.bias:
            output += self.b
        output = self.activation(output) if self.activation is not None else output
        return output

        Batch-wise graph convolution operation on given n support adj matrices
        :param G: support adj matrices - torch.Tensor (K, n_nodes, n_nodes)
        :param x: graph feature/signal - torch.Tensor (batch_size, n_nodes, input_dim)
        :return: hidden representation - torch.Tensor (batch_size, n_nodes, hidden_dim)
        
Batch-wise graph convolution operation on given n support adj matrices
Batch - wise graph convolution operation on given n support adj matrices
def forward(self, G: torch.Tensor, x: torch.Tensor):
        assert self.K == G.shape[0]
        support_list = list()
        for k in range(self.K):
            support = torch.einsum('ij,bjp->bip', [G[k, :, :], x])
            support_list.append(support)
        support_cat = torch.cat(support_list, dim=-1)
        output = torch.einsum('bip,pq->biq', [support_cat, self.W])
        if self.bias:
            output += self.b
        output = self.activation(output) if self.activation is not None else output
        return output
def forward ( self , G : torch . Tensor , x : torch . Tensor ) : assert self . K == G . shape [ 0 ] support_list = list ( ) for k in range ( self . K ) : support = torch . einsum ( 'ij,bjp->bip' , [ G [ k , : , : ] , x ] ) support_list . append ( support ) support_cat = torch . cat ( support_list , dim = - 1 ) output = torch . einsum ( 'bip,pq->biq' , [ support_cat , self . W ] ) if self . bias : output += self . b output = self . activation ( output ) if self . activation is not None else output return output
Batch-wise graph convolution operation on given n support adj matrices
Batch - wise graph convolution operation on given n support adj matrices
'''
        Batch-wise graph convolution operation on given n support adj matrices
        :param G: support adj matrices - torch.Tensor (K, n_nodes, n_nodes)
        :param x: graph feature/signal - torch.Tensor (batch_size, n_nodes, input_dim)
        :return: hidden representation - torch.Tensor (batch_size, n_nodes, hidden_dim)
        '''
hidden representation - torch.Tensor (batch_size, n_nodes, hidden_dim)
hidden representation - torch . Tensor ( batch_size n_nodes hidden_dim )
self
G
torch.Tensor
support adj matrices - torch.Tensor (K, n_nodes, n_nodes)
support adj matrices - torch . Tensor ( K n_nodes n_nodes )
x
torch.Tensor
graph feature/signal - torch.Tensor (batch_size, n_nodes, input_dim)
graph feature / signal - torch . Tensor ( batch_size n_nodes input_dim )