Safemotion Lib
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
gcn_utils.GCNBlock Class Reference
Inheritance diagram for gcn_utils.GCNBlock:

Public Member Functions

 __init__ (self, in_channels, out_channels, kernel_size, t_kernel_size=1, t_stride=1, t_padding=0, t_dilation=1, bias=True)
 
 forward (self, x, A)
 

Public Attributes

 kernel_size
 
 conv
 

Detailed Description

The basic module for applying a graph convolution.

Args:
    in_channels (int): Number of channels in the input sequence data
    out_channels (int): Number of channels produced by the convolution
    kernel_size (int): Size of the graph convolving kernel
    t_kernel_size (int): Size of the temporal convolving kernel
    t_stride (int, optional): Stride of the temporal convolution. Default: 1
    t_padding (int, optional): Temporal zero-padding added to both sides of
        the input. Default: 0
    t_dilation (int, optional): Spacing between temporal kernel elements.
        Default: 1
    bias (bool, optional): If ``True``, adds a learnable bias to the output.
        Default: ``True``

Shape:
    - Input[0]: Input graph sequence in :math:`(N, in_channels, T_{in}, V)` format
    - Input[1]: Input graph adjacency matrix in :math:`(K, V, V)` format
    - Output[0]: Outpu graph sequence in :math:`(N, out_channels, T_{out}, V)` format
    - Output[1]: Graph adjacency matrix for output data in :math:`(K, V, V)` format

    where
        :math:`N` is a batch size,
        :math:`K` is the spatial kernel size, as :math:`K == kernel_size[1]`,
        :math:`T_{in}/T_{out}` is a length of input/output sequence,
        :math:`V` is the number of graph nodes. 

Definition at line 4 of file gcn_utils.py.

Constructor & Destructor Documentation

◆ __init__()

gcn_utils.GCNBlock.__init__ ( self,
in_channels,
out_channels,
kernel_size,
t_kernel_size = 1,
t_stride = 1,
t_padding = 0,
t_dilation = 1,
bias = True )

Definition at line 34 of file gcn_utils.py.

42 bias=True):
43 super().__init__()
44
45 self.kernel_size = kernel_size
46 self.conv = nn.Conv2d(
47 in_channels,
48 out_channels * kernel_size,
49 kernel_size=(t_kernel_size, 1),
50 padding=(t_padding, 0),
51 stride=(t_stride, 1),
52 dilation=(t_dilation, 1),
53 bias=bias)
54

Member Function Documentation

◆ forward()

gcn_utils.GCNBlock.forward ( self,
x,
A )

Definition at line 55 of file gcn_utils.py.

55 def forward(self, x, A):
56 assert A.size(0) == self.kernel_size
57
58 x = self.conv(x)
59
60 n, kc, t, v = x.size()
61 x = x.view(n, self.kernel_size, kc//self.kernel_size, t, v)
62 x = torch.einsum('nkctv,kvw->nctw', (x, A))
63
64 return x.contiguous(), A

Member Data Documentation

◆ conv

gcn_utils.GCNBlock.conv

Definition at line 46 of file gcn_utils.py.

◆ kernel_size

gcn_utils.GCNBlock.kernel_size

Definition at line 45 of file gcn_utils.py.


The documentation for this class was generated from the following file: