def run_debug_base(args, num_conv_layers: int, exp_params): name = "Learning-rate-debug_ncl_"+str(num_conv_layers) cp = MultipleLayersParams() cp.compute_reconstruction = False cp.conv_classes = ConvLayer cp.sp_buffer_size = 6000 cp.sp_batch_size = 4000 cp.learning_rate = 0.10005 cp.cluster_boost_threshold = 1000 cp.max_encountered_seqs = 2000 cp.max_frequent_seqs = 1000 cp.seq_lookahead = 1 cp.seq_length = 5 if num_conv_layers == 2: cp.n_cluster_centers = [100, 230] cp.rf_size = [(8, 8), (4, 4)] cp.rf_stride = [(8, 8), (1, 1)] cp.num_conv_layers = 2 else: cp.n_cluster_centers = 200 cp.rf_size = (8, 8) cp.rf_stride = (8, 8) cp.num_conv_layers = 1 tp = MultipleLayersParams() tp.n_cluster_centers = 100 tp.sp_buffer_size = 3000 tp.sp_batch_size = 2000 tp.learning_rate = 0.01 tp.cluster_boost_threshold = 1000 tp.compute_reconstruction = True cf_easy = [1, 2, 3, 4] size = SeDatasetSize.SIZE_64 size_int = (size.value, size.value, 3) params = [ { 'se_group': {'class_filter': cf_easy, 'image_size': size}, 'model': {'conv_layers_params': cp, 'top_layer_params': tp, 'image_size': size_int} } ] exp_params.experiment_params.num_layers = num_conv_layers + 1 # needs to be there run_measurement(name, params, args, exp_params)
def _create_and_connect_agent(self, input_image: MemoryBlock, input_size: Tuple[int, int, int]): params = MultipleLayersParams() params.num_conv_layers = 4 params.n_flocks = [5, 5, 1, 1] params.n_cluster_centers = [30, 60, 60, 9] params.compute_reconstruction = True params.conv_classes = SpConvLayer params.sp_buffer_size = 5000 params.sp_batch_size = 500 params.learning_rate = 0.1 params.cluster_boost_threshold = 1000 params.max_encountered_seqs = 1000 params.max_frequent_seqs = 500 params.seq_lookahead = 2 params.seq_length = 4 params.exploration_probability = 0 params.rf_size = (2, 2) params.rf_stride = None ta_group = NCMGroup(conv_layers_params=params, model_seed=None, image_size=input_size) self.add_node(ta_group) Connector.connect(input_image, ta_group.inputs.image)
def _create_and_connect_agent(self, input_image: MemoryBlock, output_reconstruction: InputSlot, input_size: Tuple[int, int, int]): params = MultipleLayersParams() params.num_conv_layers = 3 params.n_cluster_centers = [28, 14, 7] params.compute_reconstruction = True params.conv_classes = ConvLayer params.sp_buffer_size = 5000 params.sp_batch_size = 500 params.learning_rate = 0.2 params.cluster_boost_threshold = 1000 params.max_encountered_seqs = 1000 params.max_frequent_seqs = 500 params.seq_lookahead = 2 params.seq_length = 4 params.exploration_probability = 0 params.rf_size = [(input_size[0], input_size[1]), (1, 1), (1, 1)] params.rf_stride = None ta_group = R1NCMGroup(conv_layers_params=params, model_seed=None, image_size=input_size) self.add_node(ta_group) Connector.connect(input_image, ta_group.inputs.image) Connector.connect(ta_group.outputs.predicted_reconstructed_input, output_reconstruction)
def multiple_runs_class_filter_example(args, debug: bool = False): name = "example_multiple_runs" cp = MultipleLayersParams() cp.compute_reconstruction = True cp.conv_classes = [ConvLayer, ConvLayer] cp.num_conv_layers = 2 cp.rf_stride = (8, 8) cp.rf_size = (8, 8) tp = MultipleLayersParams() tp.n_cluster_centers = 250 # class filter changed params = [{ 'class_filter': [1, 2] }, { 'class_filter': [1, 2, 3] }, { 'class_filter': [1] }] common_params = { 'conv_layers_params': cp, 'top_layer_params': tp, 'image_size': SeDatasetSize.SIZE_64, 'noise_amp': 0.0, 'model_seed': None, 'baseline_seed': None } # merge the params and common params p = ExperimentTemplateBase.add_common_params(params, common_params) run_measurement(name, p, args, debug=debug)
def make_test_params(): cp = MultipleLayersParams() cp.compute_reconstruction = True cp.conv_classes = ConvLayer cp.sp_buffer_size = 6000 cp.sp_batch_size = 4000 cp.learning_rate = 0.02 cp.cluster_boost_threshold = 1000 cp.max_encountered_seqs = 10000 cp.max_frequent_seqs = 1000 cp.seq_length = 4 cp.seq_lookahead = 1 cp.num_conv_layers = 1 cp.n_cluster_centers = 400 cp.rf_size = (8, 8) cp.rf_stride = (8, 8) tp = MultipleLayersParams() tp.n_cluster_centers = 250 tp.sp_buffer_size = 4000 tp.sp_batch_size = 500 tp.learning_rate = 0.2 tp.cluster_boost_threshold = 1000 tp.compute_reconstruction = True common_params = { 'conv_layers_params': cp, 'top_layer_params': tp, 'image_size': SeDatasetSize.SIZE_64, 'class_filter': [1, 2, 3], 'noise_amp': 0.0, 'model_seed': None, 'baseline_seed': None } changing_params = [{ 'conv_layers_params': cp.change(learning_rate=0.1) }, { 'conv_layers_params': cp.change(learning_rate=0.2), 'top_layer_params': tp.change(learning_rate=0.1) }, { 'conv_layers_params': cp.change(learning_rate=0.3) }] params = ExperimentTemplateBase.add_common_params(changing_params, common_params) return params, common_params, changing_params
def run_two_layer_net_new(args, debug: bool = False): """An example of the new experiment configuration""" name = "two_layer_new" two = [2, 15] four = [2, 15, 4, 7] six = [2, 15, 4, 7, 10, 19] cp = MultipleLayersParams() cp.compute_reconstruction = True cp.conv_classes = ConvLayer cp.sp_buffer_size = 6000 cp.sp_batch_size = 4000 cp.learning_rate = 0.02 cp.cluster_boost_threshold = 1000 cp.max_encountered_seqs = 10000 cp.max_frequent_seqs = 1000 cp.seq_length = 4 cp.seq_lookahead = 1 cp.num_conv_layers = 1 cp.n_cluster_centers = 400 cp.rf_size = (8, 8) cp.rf_stride = (8, 8) tp = MultipleLayersParams() tp.n_cluster_centers = 250 tp.sp_buffer_size = 4000 tp.sp_batch_size = 500 tp.learning_rate = 0.2 tp.cluster_boost_threshold = 1000 tp.compute_reconstruction = True params = [{ 'conv_layers_params': cp, 'top_layer_params': tp, 'image_size': SeDatasetSize.SIZE_64, 'class_filter': six, 'noise_amp': 0.0, 'model_seed': None, 'baseline_seed': None }] run_measurement(name, params, args, debug=debug, num_layers=2)
def good_one_layer_config_for_four_objects() -> List[Dict[str, Any]]: """A topology which might achieve 100% SE accuracy on 4 objects""" cp = MultipleLayersParams() cp.compute_reconstruction = False cp.conv_classes = ConvLayer cp.sp_buffer_size = 6000 cp.sp_batch_size = 4000 cp.learning_rate = 0.1 cp.cluster_boost_threshold = 1000 cp.max_encountered_seqs = 2000 cp.max_frequent_seqs = 1000 cp.seq_lookahead = 1 cp.seq_length = 5 cp.n_cluster_centers = 200 cp.rf_size = (8, 8) cp.rf_stride = (8, 8) cp.num_conv_layers = 1 tp = MultipleLayersParams() tp.n_cluster_centers = 150 tp.sp_buffer_size = 3000 tp.sp_batch_size = 2000 tp.learning_rate = 0.15 tp.cluster_boost_threshold = 1000 tp.compute_reconstruction = True cf_easy = [1, 2, 3, 4] size = SeDatasetSize.SIZE_64 size_int = (size.value, size.value, 3) params = [ { 'se_group': {'class_filter': cf_easy, 'image_size': size}, 'model': {'conv_layers_params': cp.change(opp=0.5), 'top_layer_params': tp, 'image_size': size_int} } ] return params
def multiple_runs_lr_example(args, debug: bool = False): name = "example_multiple_runs" default_conv = MultipleLayersParams() default_conv.compute_reconstruction = True default_conv.conv_classes = [ConvLayer, SpConvLayer] default_conv.num_conv_layers = 2 default_conv.rf_stride = (8, 8) default_conv.rf_size = (8, 8) tp = MultipleLayersParams() tp.n_cluster_centers = 250 params = [{ 'conv_layers_params': default_conv.change(learning_rate=0.1) }, { 'conv_layers_params': default_conv.change(learning_rate=0.2), 'top_layer_params': tp.change(learning_rate=0.11) }, { 'conv_layers_params': default_conv.change(learning_rate=0.3) }] common_params = { 'top_layer_params': tp, 'image_size': SeDatasetSize.SIZE_64, 'noise_amp': 0.0, 'model_seed': None, 'baseline_seed': None } # merge the params and common params p = ExperimentTemplateBase.add_common_params(params, common_params) run_measurement(name, p, args, debug=debug)
def run_opp(args, num_conv_layers: int, exp_params, top_cc: int = 150): name = f"OPP-influence_num_cc{top_cc}" cp = MultipleLayersParams() cp.compute_reconstruction = False cp.conv_classes = ConvLayer cp.sp_buffer_size = 6000 cp.sp_batch_size = 1500 # original 4000 cp.learning_rate = 0.10001 cp.cluster_boost_threshold = 1000 cp.max_encountered_seqs = 2000 cp.max_frequent_seqs = 1000 cp.seq_lookahead = 1 cp.seq_length = 4 # note: might use also 5 (as in older experiments) if num_conv_layers == 2: cp.n_cluster_centers = [100, 230] cp.rf_size = [(8, 8), (4, 4)] cp.rf_stride = [(8, 8), (1, 1)] cp.num_conv_layers = 2 else: cp.n_cluster_centers = 200 cp.rf_size = (8, 8) cp.rf_stride = (8, 8) cp.num_conv_layers = 1 tp = MultipleLayersParams() tp.n_cluster_centers = top_cc tp.sp_buffer_size = 3000 tp.sp_batch_size = 1500 # tp.learning_rate = 0.15 tp.cluster_boost_threshold = 1000 tp.compute_reconstruction = True cf_easy = [1, 2, 3, 4] size = SeDatasetSize.SIZE_64 size_int = (size.value, size.value, 3) params = [ { 'se_group': {'class_filter': cf_easy, 'image_size': size}, 'model': {'conv_layers_params': cp.change(opp=0), 'top_layer_params': tp, 'image_size': size_int} }, { 'se_group': {'class_filter': cf_easy, 'image_size': size}, 'model': {'conv_layers_params': cp.change(opp=0.05), 'top_layer_params': tp, 'image_size': size_int} }, { 'se_group': {'class_filter': cf_easy, 'image_size': size}, 'model': {'conv_layers_params': cp.change(opp=0.5), 'top_layer_params': tp, 'image_size': size_int} }, { 'se_group': {'class_filter': cf_easy, 'image_size': size}, 'model': {'conv_layers_params': cp.change(opp=0.95), 'top_layer_params': tp, 'image_size': size_int} }, { 'se_group': {'class_filter': cf_easy, 'image_size': size}, 'model': {'conv_layers_params': cp.change(opp=1), 'top_layer_params': tp, 'image_size': size_int} }, # { # 'se_group': {'class_filter': cf_easy, # 'image_size': size}, # 'model': {'conv_layers_params': cp.change(opp=0.3), # 'top_layer_params': tp, # 'image_size': size_int} # }, # { # 'se_group': {'class_filter': cf_easy, # 'image_size': size}, # 'model': {'conv_layers_params': cp.change(opp=0.7), # 'top_layer_params': tp, # 'image_size': size_int} # } ] exp_params.experiment_params.num_layers = num_conv_layers + 1 # needs to be there run_measurement(name, params, args, exp_params)
def run_rf_size(args, exp_params, opp: float = 1.0): name = "rf_size" cp = MultipleLayersParams() cp.compute_reconstruction = False cp.conv_classes = ConvLayer cp.sp_buffer_size = 6000 cp.sp_batch_size = 4000 cp.learning_rate = 0.1 cp.cluster_boost_threshold = 1000 cp.max_encountered_seqs = 2000 cp.max_frequent_seqs = 1000 cp.seq_lookahead = 1 cp.seq_length = 5 cp.opp = opp cp.n_cluster_centers = 200 cp.rf_size = (8, 8) cp.rf_stride = (8, 8) cp.num_conv_layers = 1 tp = MultipleLayersParams() tp.n_cluster_centers = 150 tp.sp_buffer_size = 3000 tp.sp_batch_size = 2000 tp.learning_rate = 0.15 tp.cluster_boost_threshold = 1000 tp.compute_reconstruction = True cf_easy = [1, 2, 3, 4] size = SeDatasetSize.SIZE_64 size_int = (size.value, size.value, 3) params = [ { 'se_group': {'class_filter': cf_easy, 'image_size': size}, 'model': {'conv_layers_params': cp.change(rf_stride=([(8, 8)])), 'top_layer_params': tp, 'image_size': size_int} }, { 'se_group': {'class_filter': cf_easy, 'image_size': size}, 'model': {'conv_layers_params': cp.change(rf_stride=([(4, 4)])), 'top_layer_params': tp, 'image_size': size_int} }, { 'se_group': {'class_filter': cf_easy, 'image_size': size}, 'model': {'conv_layers_params': cp.change(rf_stride=([(2, 2)])), 'top_layer_params': tp, 'image_size': size_int} }, ] exp_params.experiment_params.num_layers = 2 # needs to be there run_measurement(name, params, args, exp_params)
cp.compute_reconstruction = True cp.conv_classes = ConvLayer cp.sp_buffer_size = 6000 cp.sp_batch_size = 4000 cp.learning_rate = 0.1 cp.cluster_boost_threshold = 1000 cp.max_encountered_seqs = 2000 cp.max_frequent_seqs = 1000 cp.seq_lookahead = 1 cp.seq_length = 5 if num_conv_layers == 2: cp.n_cluster_centers = [100, 230] cp.rf_size = (8, 8) cp.rf_stride = (8, 8) cp.num_conv_layers = 2 else: cp.n_cluster_centers = 200 cp.rf_size = (8, 8) cp.rf_stride = (8, 8) tp = None if use_top_layer: tp = MultipleLayersParams() tp.n_cluster_centers = 20 tp.sp_buffer_size = 3000 tp.sp_batch_size = 2000 tp.learning_rate = 0.1 tp.cluster_boost_threshold = 1000