Skip to content

SegFormer Training extremely slow #996

@omarequalmars

Description

@omarequalmars

I've been training a series of models implemented by this package for a while, all using 'tu-mobilevit_xxs' as an encoder. However I noticed that the latest addition, segformer, is extremely slow in training compared to the others despite being reported to have the same number of parameters by Pytorch lightning. Here is a visualization from Tensorboard:

image

And here is the parameter count reported by Lightning:

image

It's much slower than the rest in training, and considerably slows down my laptop. Why does it take so much resources despite being approximately the same size as the other models? Here are my architecture hyperparameters for reference, for every model I trained:

    h_params_Unet = {
        'encoder': encoder,
        'depth': 5,
        'Bnorm': True,
        'Attn': 'scse',
        'channels': (256, 128, 64, 32, 16),
        'lr_init': 1e-3,
        'weight_decay': 0,
        'temperature': 2,
        'Arch': "Unet"
    }

    h_params_DLV3plus = {
        'encoder': encoder,
        'depth': 5,
        'encoder_output_stride': 16,
        'channels': 512,
        'decoder_atrous_rates': (16, 32, 128),
        'lr_init': 1e-3,
        'weight_decay': 0,
        'temperature': 2,
        'Arch': "DLV3+"
    }

    h_params_MANet = {
        'encoder': encoder,               # Backbone encoder
        '
```depth': 5,                       # Number of encoder stages
        'Bnorm': True,                    # Use batch normalization in the decoder
        'channels': (256, 128, 64, 32, 16),  # Number of channels in each decoder layer
        'decoder_pab_channels': 64,
        'lr_init': 1e-3,                  # Initial learning rate
        'weight_decay': 0,                # Weight decay for regularization
        'temperature': 2,                 # Temperature for distillation
        'Arch': "MANet"
    }

    h_params_PAN = {
        'encoder': encoder,               # Backbone encoder
        'encoder_output_stride': 16,
        'channels': 512,                  # Number of channels in each decoder layer
        'lr_init': 1e-3,                  # Initial learning rate
        'weight_decay': 0,                # Weight decay for regularization
        'temperature': 2,                 # Temperature for distillation
        'Arch': "PAN"
    }

    h_params_Segformer = {
    'encoder': encoder,               # Backbone encoder
    'depth': 5,                       # Number of encoder stages
    'channels': 512,  # Number of channels in each decoder layer
    'lr_init': 1e-3,                  # Initial learning rate
    'weight_decay': 0,                # Weight decay for regularization
    'temperature': 2,                 # Temperature for distillation
    'Arch': "Segformer"
}


All of them have the same number of channels and depth where applicable. What am I doing wrong?

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