DUALPROMPT#

Arguments#

Options

--train_maskbool

Help: if using the class mask at training

  • Default: True

--pretrainedunknown

Help: Load pretrained model or not

  • Default: True

--dropfloat

Help: Dropout rate (default: 0.)

  • Default: 0.0

--drop_pathfloat

Help: Drop path rate (default: 0.)

  • Default: 0.0

--clip_gradfloat

Help: Clip gradient norm (default: None, no clipping)

  • Default: 1.0

--use_g_promptbool

Help: if using G-Prompt

  • Default: True

--g_prompt_lengthint

Help: length of G-Prompt

  • Default: 5

--g_prompt_layer_idxint

Help: the layer index of the G-Prompt

  • Default: [0, 1]

--use_prefix_tune_for_g_promptbool

Help: if using the prefix tune for G-Prompt

  • Default: True

--use_e_promptbool

Help: if using the E-Prompt

  • Default: True

--e_prompt_layer_idxint

Help: the layer index of the E-Prompt

  • Default: [2, 3, 4]

--use_prefix_tune_for_e_promptbool

Help: if using the prefix tune for E-Prompt

  • Default: True

--prompt_poolbool

Help: None

  • Default: True

--sizeint

Help: None

  • Default: 10

--lengthint

Help: None

  • Default: 5

--top_kint

Help: None

  • Default: 1

--initializerstr

Help: None

  • Default: uniform

--prompt_keybool

Help: None

  • Default: True

--prompt_key_initstr

Help: None

  • Default: uniform

--use_prompt_maskbool

Help: None

  • Default: True

--mask_first_epochbool

Help: None

  • Default: False

--shared_prompt_poolbool

Help: None

  • Default: True

--shared_prompt_keybool

Help: None

  • Default: False

--batchwise_promptbool

Help: None

  • Default: True

--embedding_keystr

Help: None

  • Default: cls

--predefined_keystr

Help: None

--pull_constraintunknown

Help: None

  • Default: True

--pull_constraint_coefffloat

Help: None

  • Default: 1.0

--same_key_valuebool

Help: None

  • Default: False

--global_poolstr

Help: type of global pooling for final sequence

  • Default: token

  • Choices: token, avg

--head_typestr

Help: input type of classification head

  • Default: token

  • Choices: token, gap, prompt, token+prompt

--freezelist

Help: freeze part in backbone model

  • Default: ['blocks', 'patch_embed', 'cls_token', 'norm', 'pos_embed']

DualPrompt: Complementary Prompting for Rehearsal-free Continual Learning

Note

WARNING: DualPrompt USES A CUSTOM BACKBONE: vit_base_patch16_224. The backbone is a ViT-B/16 pretrained on Imagenet 21k and finetuned on ImageNet 1k.

Classes#

class models.dualprompt.DualPrompt(backbone, loss, args, transform, dataset=None)[source]#

Bases: ContinualModel

DualPrompt: Complementary Prompting for Rehearsal-free Continual Learning.

COMPATIBILITY: List[str] = ['class-il', 'task-il']#
NAME: str = 'dualprompt'#
begin_task(dataset)[source]#
forward(x)[source]#
get_parameters()[source]#
static get_parser(parser)[source]#
Return type:

ArgumentParser

observe(inputs, labels, not_aug_inputs, epoch=None)[source]#