def make_test_acts(r, use_merged_h5_file=True, use_normalised_h5_file=False, h5_files_directory='', h5_list_filename='', h5_list=[]): """Makes an activation table using TestActivationTable""" if use_merged_h5_file == True: acts = kmeans.test_activation_table.TestActivationTable(mean=False) acts.add_merged_file(r.file_root + r.this_one_file_name) elif use_normalised_h5_file: acts = kmeans.test_activation_table.TestActivationTable(mean=False) acts.add_normalised_file(r.file_root + r.this_one_file_name) else: acts, h5_list = combine_h5_files_in_activation_table( h5_file_location=h5_files_directory, h5_list_filename=h5_list_filename, h5_list=h5_list, useFile=True, verbose=True) print_test_acts(acts) return acts
class_labels = short_labels deploy_file = caffe_settings.deploy_file output_directory = caffe_settings.output_directory class_dict = make_class_to_line_number_look_up_table(class_labels=r.labels) h5_list_filename = 'dir_file.txt' do_h5_files = False if do_h5_files: import Caffe_AlexNet as C C.main(r) # this makes the h5 files acts, h5_list = combine_h5_files_in_activation_table(h5_file_location=h5_files_directory, #os.path.join(file_root, 'dataset/broden1_224/images/vgg_h5'), h5_list_filename='h5_conv5_list.txt', h5_list=[], useFile=True, verbose=True) # silly little test print('{} files in table'.format(len(acts.get_all_point_indices()))) egg=acts.get_all_point_indices()[0] point=acts.get_activation(egg) print('Example file: {}, vectors are {}-dimensional'.format(point, len(point.vector))) print('Example labels: {}'.format(point.labels)) import Automation_experimental_functions as A # check by just plotting a single unit, any unit, and this also buildsthe label_dict! label_dict, found_labels, no_files_in_label = A.do_jitter_plot_test(acts, test_class_index=0,
model_file = caffe_settings.model_file this_one_file_name = caffe_settings.this_one_file_name blob = caffe_settings.blob file_root = caffe_settings.file_root class_labels = short_labels output_directory = caffe_settings.output_directory if do_h5_files: import Caffe_AlexNet as C C.main(r) # this makes the h5 files #from merger import merge_layer #merge_layer(os.getcwd(), 'inception4e', '100ActsOnly', 'all') acts, h5_list = combine_h5_files_in_activation_table( h5_file_location=h5_files_directory, h5_list_filename='h5_list.txt', h5_list=[], useFile=True, verbose=True) # silly little test print_test_acts(acts) class_dict = make_class_to_line_number_look_up_table(class_labels=class_labels, verbose=False) ####### # this builds the look-up table between points and the class they are in ## This bit is sslow, it loads the label data for all acts
this_one_file_name = caffe_settings.this_one_file_name blob = caffe_settings.blob file_root = caffe_settings.file_root class_labels = short_labels h5_list_filename = 'dir_file.txt' import Caffe_AlexNet2 as C C.main(r) # this makes the h5 files acts = kmeans.activation_table.ActivationTable( mean=False) # this sets up the activation table object acts, h5_list = combine_h5_files_in_activation_table( h5_file_location=file_root + '/dataset/broden1_227/images/', h5_list_filename='h5_list.txt', h5_list=[], useFile=True, verbose=True) # silly little test print_test_acts(acts) import Automation_experimental_functions as A # check by just plotting a single unit, any unit, and this also buildsthe label_dict! label_dict, found_labels, no_files_in_label = A.do_jitter_plot_test( acts, test_class_index=0, current_neuron_index=0, label_dict='', found_labels='',