Confused with ".act = nn.Identity()"

I am trying to understand a model implementation where there is this following layer. I don’t understand what the last line means.

class Model(nn.Module):
    def __init__(self,
                 num_class,
                 num_point,
                 num_person,
                 num_gcn_scales,
                 num_g3d_scales,
                 graph,
                 in_channels=3):
        super(Model, self).__init__()

        Graph = import_class(graph)
        A_binary = Graph().A_binary
        
        self.sgcn2 = nn.Sequential(
        MS_GCN(num_gcn_scales, c1, c1, A_binary, disentangled_agg=True),
        MS_TCN(c1, c2, stride=2),
        MS_TCN(c2, c2))
        self.sgcn2[-1].act = nn.Identity()

It looks like the model first perform spatial graph convolution followed by two temporal convolution. But what happens with this line self.sgcn2[-1].act = nn.Identity()

Your suggestions will greatly help. Thanks.

Hi,

self.sgcn2 is sequential of MS_GCN, MS_TCN, and MS_TCN.
So, self.sgcn2[-1] refers to the last MS_TCN.
self.sgcn2[-1].act is either the attribute or member variable of an instance of MS_TCN. From that name, I guess by default MS_TCN has some activation function such as Sigmoid and ReLU. Though the author of that snippet wanted that last module to use Identity as its activation.

Thank you so much. That is exactly the case, there is a activation function in MS_TCN and act holds the value that determines what the activation will be.