def main(): parser = get_stimuli_compute_parser() args = parser.parse_args() os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu assert args.set_func, "Must specify set_func" args = bs_fit.load_set_func(args) compute_aggregate_dump(args, builder=StimuliCompute)
def main(): parser = get_compute_raw_response_parser() args = parser.parse_args() os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu assert args.set_func, "Must specify set_func" args = bs_fit.load_set_func(args) raw_stimuli_compute = RawStimuliCompute(args) input_images = np.load(args.file_path)[:args.batch_size] output = raw_stimuli_compute.get_output(input_images) print(np.trace(output[:, :args.batch_size]))
def main(): parser = get_circular_var_parser() args = parser.parse_args() os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu assert args.set_func, "Must specify set_func" args = bs_fit.load_set_func(args) cir_var_compute = CircularVarCompute(args) layers = cir_var_compute.layers for which_split in range(4): cir_var_compute.which_split = which_split for layer in tqdm(layers): cir_var_compute.compute_save_cir_var(layer)
def main(): parser = get_lucid_stimuli_compute_parser() args = parser.parse_args() os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu assert args.set_func, "Must specify set_func" args = bs_fit.load_set_func(args) layers = bs_fit.TF_RES18_LAYERS if getattr(args, 'layers', None) is not None: layers = args.layers.split(',') for layer in tqdm(layers): layer, image, all_losses = get_vm_model_image_losses(args, layer=layer) #layer, image, all_losses = get_lucid_orig_image_losses(args) dump_results(args, layer, image, all_losses)
def main(): parser = get_raw_pt_stimuli_compute_parser() args = parser.parse_args() os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu assert args.set_func, "Must specify set_func" args = bs_fit.load_set_func(args) batch_size = 16 num_batches = args.num_batches #batch_size = 4 #num_batches = 16 #for layer in tqdm(['layer2.1.relu', 'layer4.1.relu']): layer_list = bs_fit.PT_RES18_LAYERS if args.layer_start_idx is not None: layer_end_idx = args.layer_start_idx + args.layer_len_idx layer_list = layer_list[\ args.layer_start_idx : layer_end_idx] for layer in tqdm(layer_list): all_save_results = [] for start_idx in range(0, num_batches * batch_size, batch_size): #stimuli_compute = RawPtStimuliCompute(args, start_idx, batch_size) stimuli_compute = FFTRawPtStimuliCompute( args, start_idx + (args.global_start_idx or 0), batch_size) save_result = stimuli_compute.compute_optimal_stimuli(layer) all_save_results.append(save_result) del stimuli_compute images = [] loss_vals = [] actual_response = [] for save_result in all_save_results: images.append(save_result['images']) loss_vals.append(save_result['loss_vals']) actual_response.append(save_result['actual_response']) images = np.concatenate(images, axis=0) loss_vals = np.sum(loss_vals, axis=0) actual_response = np.concatenate(actual_response, axis=0) final_save_result = { 'images': images, 'loss_vals': loss_vals, 'actual_response': actual_response, } dump_result(final_save_result, args.identifier, layer, args.global_start_idx)