from generation import transform from Experiment import Experiment from os import path from tools import sec_to_time, gen_datestr from time import time from tools import check_folder # Record start time for this experiment start_time = time() start_date = gen_datestr() print(f"---- Started experiment : {start_date}") # %% # Determine name for save folder report_folder = '/home/ronimber/PycharmProjects/temporal-coding/results/experiments/30_neurons/50_hz' # Make sure the folder exists, create with all subfolders if it does not check_folder(report_folder) # Name of files from current condition condition_name = 'interval=(1, 3)_relprob=0.25_relduration=6_' # Main shared parameters number_of_repetitions = 30 set_size = 200 fraction_training = 0.5 stimulus_duration = 500 # Machine learning model parameters model_params = dict( tau=2, # Voltage time decay constant threshold= 0.025 # Threshold for firing, firing will result in a "1" classification )
main_conditions) # Creating list with dictionary for each condition for condition in conditions_list: condition_params = shared_conditions.copy( ) # Grabbing the shared conditios condition_params.update(condition) # Adding current conditions # Setting the threshold and learning rate condition_params['threshold'] = number_of_neuron_params[ condition['number_of_neurons']]['threshold'] condition_params['learning_rate'] = number_of_neuron_params[ condition['number_of_neurons']]['learning_rate'] # Determine location and name of generated template file condition_report_folder = os.path.join( save_folder, f"{condition['number_of_neurons']}_neurons", f"{condition['frequency']}_hz") check_folder(condition_report_folder) condition_name = f"interval={condition_params['interval']}_relprob={condition_params['release_probability']}_relduration={condition_params['release_duration']}_" # Adding to params dictionary condition_params['report_folder'] = condition_report_folder condition_params['condition_name'] = condition_name target_file = os.path.join(condition_report_folder, f'{condition_name}experiment_template.py') # Creating template text target_contents = template.substitute(condition_params) # Saving template with open(target_file, 'w') as file: file.write(target_contents) # target_contents = template.substitute(substitutions)
print(f"---- Started experiment : {start_date}") # %% Specific parameters for parameter selection, easier to control from here threshold = 250e-3 learning_rate = 5e-5 # %% Parameter specification # Set location of root report (results) folder # report_folder = '/home/ron/OneDrive/Documents/Masters/Parnas/temporal-coding/Results/' # For laptop report_folder = '/home/ronimber/PycharmProjects/temporal-coding/Results/' # For Google-Compute-Engine # Optional: Set ordered sub-folders according to condition keywords condition_folders = ('parameter_selection', '30_neurons', '15_hz', 'interval_(1-3)') # If empty, saves at report folder # Determine name for save folder save_folder = path.join(report_folder, *condition_folders) # Make sure the folder exists, create with all subfolders if it does not check_folder(save_folder) # Optional: Set custom name for the experiment, useful when running several experiments with some shared conditions, # All experiment related files will have this name prepended to them with an underscore experiment_name = f'thresh={threshold}_lrnRate={learning_rate}' # This can be left empty to save without experiment name # Base experiment parameters number_of_repetitions = 10 # Number of times to repeat the experiment with the exact same conditions set_size = 200 # The size of the set(s) to generate for this experiment fraction_training = 0.5 # Fraction of samples to be used in training, the rest go to testing stimulus_duration = 500 # Maximal duration of the stimulus # Machine learning model parameters model_params = dict( tau=2, # Voltage time decay constant threshold=
the spikes in the original stimulus are allowed to shift, for this purpose a symmetric interval shift is used, allowing each spike to move forward or backward in time within a specified interval. ''' # %% from generation import make_stimulus from generation.transform import symmetric_interval_shift from tools import calc_stimuli_distance, check_folder, time_tools import numpy as np import os import datetime # %% # Set up file saving target_folder = '/mnt/disks/data' # Set up where the sets will be saved check_folder(target_folder) # Stimuli generation parameters frequencies = [15, 50, 100] number_of_neurons = [30, 150, 500] duration = 500 # Units: ms # Pair generation parameters number_of_pairs = 100 # Number of stimulus pairs for each interval condition # Intervals to use for temporal shifting temporal_shift_intervals = [[3, 5], [3, 7], [3, 10], [3, 15]] # Units: Seconds # %% current_date = time_tools(with_time=False) for num_neur in number_of_neurons: