ice
ice copied to clipboard
How to get a subspace in W+?
An excellent work. But there are some questions for me.How can I get a subspace that dosen't change the selected region in W+ space? And how much time it cost? Hope you can help me.
You can refer to the following code in the discover_subspace.ipynb.
if task == 'eye_photo_act_mp_sup_mp':
for space, magnitude in zip(['s'], [20]): # zip(['s', 'w+', 'w', 'z'], [8, 2, 2, 1]):
dataloader = dataloader_to(zs0[:2], space)
nose_segmenter = FaceSegmenter(segmenter_path, mask_labels=[4, 5, 6], morphology='dilation', ks_ratio=0.1).to(device)
f_photo = MaskedMSE(generator, space, nose_segmenter, (48, 48), return_complementary=True)
JtJs_photo = load_or_compute(cache_path % (space, task, 'photo'), lambda: find_jtj_direct(f_photo, dataloader), recompute=False, map_location=device)
with torch.no_grad():
s_act, v_act = compute_early_projected_pca(JtJs_photo[0],[JtJs_photo[1]], sup_ratio=[1e-3])
torch.save([s_act, v_act], span_path % (space, task))
visualize(zs0[[21, 30]], space, magnitude, v_act, steps=[ -1, 1], selector=range(10))
Basically this code changes the region marked by nose_segmenter (wrong name, should be eye_segmenter) while preserving the rest region (as you need). For W+ space, just assign "w+" to space.