MCPcopy Create free account
hub / github.com/LAMDA-CL/CVPR22-Fact / update_fc

Method update_fc

models/fact/Network.py:129–143  ·  view source on GitHub ↗
(self,dataloader,class_list,session)

Source from the content-addressed store, hash-verified

127 raise ValueError('Unknown mode')
128
129 def update_fc(self,dataloader,class_list,session):
130 for batch in dataloader:
131 data, label = [_.cuda() for _ in batch]
132 data=self.encode(data).detach()
133
134 if self.args.not_data_init:
135 new_fc = nn.Parameter(
136 torch.rand(len(class_list), self.num_features, device="cuda"),
137 requires_grad=True)
138 nn.init.kaiming_uniform_(new_fc, a=math.sqrt(5))
139 else:
140 new_fc = self.update_fc_avg(data, label, class_list)
141
142 if 'ft' in self.args.new_mode: # further finetune
143 self.update_fc_ft(new_fc,data,label,session)
144
145 def update_fc_avg(self,data,label,class_list):
146 new_fc=[]

Callers 1

trainMethod · 0.45

Calls 3

encodeMethod · 0.95
update_fc_avgMethod · 0.95
update_fc_ftMethod · 0.95

Tested by

no test coverage detected