Skip to content

ncdia.model

ncdia.models.models

get_network(config)

load model.

Parameters:

  • trainer(config): model config

ncdia.models.net.inc_net

BaseNet

BaseNet for incremental learning.

__init__(self, network, base_classes, num_classes, att_classes, net_alice, mode)

The constructor method that initializes an instance of BaseNet.

Parameters:

  • network (config): The config of the network.
  • base_classes(int): The number of base classes.
  • num_classes(int): The total class number.
  • att_classes(int): The attribute class number.
  • mode(str): classifier mode.

feature_dim(self)

The feature dimension of the network.

Returns:

  • out_dim(int) feature dimension of the network.

extractor_vector(self, x)

get features of input x.

Parameters:

  • x(tensor): input data.

Returns:

  • out_features(tensor) features of the input.

forward(self, x)

forworad pass of the network.

Parameters:

  • x(tensor): input data.

Returns:

  • results (dict): forward pass results. Contains the following keys:
    • "fmaps": [x_1, x_2, ..., x_n],
    • "features": features
    • "logits": logits

copy(self)

copy.

Returns:

  • copy function.

freeze(self)

freeze parameters.

IncrementalNet

Incremental Network which follows BaseNet.

__init__(self, network, base_classes, num_classes, att_classes, net_alice, mode)

The constructor method that initializes an instance of BaseNet.

Parameters:

  • network (config): The config of the network.
  • base_classes(int): The number of base classes.
  • num_classes(int): The total class number.
  • att_classes(int): The attribute class number.
  • mode(str): classifier mode.

update_fc(self, nb_classes)

Update fc parameter, generate new fc and copy old parameter.

Parameters:

  • network (int): New class number.

Returns:

  • fc: updated fc layers.

generate_fc(self, in_dim, out_dim)

Parameters:

  • in_dim (int): new fc in dimension.
  • out_dim (int): new fc out dimension.

Returns:

  • fc: new fc layers.

forward(self, x)

forworad pass of the network.

Parameters:

  • x(tensor): input data.

Returns:

  • results (dict): forward pass results. Contains the following keys:
    • "fmaps": [x_1, x_2, ..., x_n],
    • "features": features
    • "logits": logits

weight_align(self, increment)

Normalize classifer parameters.

Parameters:

  • increment(int): incremental classes.