Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions domainlab/algos/builder_matchdg.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def init_business(self, exp):
i_c=task.isize.i_c,
i_h=task.isize.i_h,
i_w=task.isize.i_w)
# different than model, ctr_model has no classification so it has
# different wrapper
ctr_model = ModelWrapMatchDGNet(ctr_net, list_str_y=task.list_str_y)
ctr_model = ctr_model.to(device)

Expand Down
9 changes: 8 additions & 1 deletion domainlab/models/a_model_classif.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ def evaluate(self, loader_te, device):
logger = Logger.get_logger()
logger.info(f"before training, model accuracy: {acc}")

def extract_semantic_feat(self, tensor_x):
"""
by default, use the logit as extracted feature if the current method
is not being overriden by child class
"""
return self.cal_logit_y(tensor_x)

@abc.abstractmethod
def cal_logit_y(self, tensor_x):
"""
Expand Down Expand Up @@ -199,4 +206,4 @@ def cal_reg_loss(self, tensor_x, tensor_y, tensor_d, others=None):
"""
device = tensor_x.device
bsize = tensor_x.shape[0]
return [torch.zeros(bsize, 1).to(device)], [0.0]
return [torch.zeros(bsize, 1).to(device)], [0.0]
6 changes: 6 additions & 0 deletions test_match_duva.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
python main_out.py --te_d 0 1 2 --tr_d 3 7 --task=mnistcolor10 --debug --bs=2 --aname=matchhduva \
--epochs_ctr=3 --epos=6 --nname=conv_bn_pool_2 --gamma_y=7e5 \
--nname_topic_distrib_img2topic=conv_bn_pool_2 \
--nname_encoder_sandwich_layer_img2h4zd=conv_bn_pool_2


4 changes: 4 additions & 0 deletions test_match_duva_vlcs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
python main_out.py --te_d=caltech --task=mini_vlcs --debug --bs=2 --aname=matchhduva \
--epochs_ctr=3 --epos=6 --npath=examples/nets/resnet.py --gamma_y=7e5 \
--npath_topic_distrib_img2topic=examples/nets/resnet.py \
--npath_encoder_sandwich_layer_img2h4zd=examples/nets/resnet.py