Skip to content

ff_layer weights sharing #3

Description

@RispaXyl

Hi! It seems that in TransformerEncoder each TransformerLayer uses the same ff_layer weights that are instantiated once. Is this intentional?

        if ff_layer is None:
            ff_layer =  torch.nn.Sequential(torch.nn.Linear(model_dim, ff_dim),
                                            torch.nn.ReLU(),
                                            torch.nn.Linear(ff_dim, model_dim))
        else:
            ff_layer = ff_layer()
        if cross_attention_layer is not None:
            cross_attention_layer = cross_attention_layer()
        self.encoder_layers = torch.nn.ModuleList([TransformerLayer(model_dim, 
                                                    attention_layer(), 
                                                    ff_layer, 
                                                    norm_layer, 
                                                    norm_type, 
                                                    cross_attention_layer,
                                                    drop_path,
                                                    init_values) for i in range(num_layers)])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions