in_features = tg_model.fc.in_features out_features = tg_model.fc.out_features print("in_features:", in_features, "out_features:", out_features) ref_model = None elif b == first_batch_number + 1: ############################################################ last_iter = b ############################################################ #increment classes ref_model = copy.deepcopy(tg_model) in_features = tg_model.fc.in_features out_features = tg_model.fc.out_features print("in_features:", in_features, "out_features:", out_features) new_fc = modified_linear.SplitCosineLinear( in_features, out_features, P) new_fc.fc1.weight.data = tg_model.fc.weight.data new_fc.sigma.data = tg_model.fc.sigma.data tg_model.fc = new_fc lamda_mult = out_features * 1.0 / P else: ############################################################ last_iter = b ############################################################ ref_model = copy.deepcopy(tg_model) in_features = tg_model.fc.in_features out_features1 = tg_model.fc.fc1.out_features out_features2 = tg_model.fc.fc2.out_features print("in_features:", in_features, "out_features1:", \ out_features1, "out_features2:", out_features2) new_fc = modified_linear.SplitCosineLinear(
tg_model = modified_resnet.resnet18(num_classes=args.nb_cl_fg) in_features = tg_model.fc.in_features out_features = tg_model.fc.out_features print("in_features:", in_features, "out_features:", out_features) ref_model = None elif iteration == start_iter + 1: ############################################################ last_iter = iteration ############################################################ #increment classes ref_model = copy.deepcopy(tg_model) in_features = tg_model.fc.in_features out_features = tg_model.fc.out_features print("in_features:", in_features, "out_features:", out_features) new_fc = modified_linear.SplitCosineLinear(in_features, out_features, args.nb_cl) new_fc.fc1.weight.data = tg_model.fc.weight.data new_fc.sigma.data = tg_model.fc.sigma.data tg_model.fc = new_fc lamda_mult = out_features * 1.0 / args.nb_cl else: ############################################################ last_iter = iteration ############################################################ ref_model = copy.deepcopy(tg_model) in_features = tg_model.fc.in_features out_features1 = tg_model.fc.fc1.out_features out_features2 = tg_model.fc.fc2.out_features print("in_features:", in_features, "out_features1:", \ out_features1, "out_features2:", out_features2)