DUALPROMPT#

Arguments#

Options

--pretrained0|1|True|False -> bool

Help: Load pretrained model or not

  • Default: 1

--use_fix_permute0|1|True|False -> bool

Help: Apply fix to reshape issue from original implementation (ref: issue #56)

  • Default: 0

--clip_gradfloat

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

  • Default: 1.0

--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_prompt0|1|True|False -> bool

Help: if using the prefix tune for G-Prompt

  • Default: 1

--e_prompt_layer_idxint

Help: the layer index of the E-Prompt

  • Default: [2, 3, 4]

--use_prefix_tune_for_e_prompt0|1|True|False -> bool

Help: if using the prefix tune for E-Prompt

  • Default: 1

--sizeint

Help: None

  • Default: 10

--lengthint

Help: None

  • Default: 5

--top_kint

Help: None

  • Default: 1

--initializerstr

Help: None

  • Default: uniform

--prompt_key_initstr

Help: None

  • Default: uniform

--batchwise_prompt0|1|True|False -> bool

Help: Use batch-wise promting? (NOTE: This should be avoided as it is not a fair comparison with other methods.)

  • Default: 1

--embedding_keystr

Help: None

  • Default: cls

--predefined_keystr

Help: None

--pull_constraint0|1|True|False -> bool

Help: None

  • Default: 1

--pull_constraint_coefffloat

Help: None

  • Default: 1.0

--same_key_value0|1|True|False -> bool

Help: None

  • Default: 0

--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]#