Esempio n. 1
0
                    action='store',
                    dest='num_epochs',
                    type=int,
                    default=2)

parser.add_argument('--gpu', action="store_true", default=False)

results = parser.parse_args()

data_dir_in = results.data_dir
arch_in = results.arch
save_dir_in = results.save_dir
lr_in = results.lr
hidden_size = results.h_units
epochs = results.num_epochs
gpu_on = results.gpu

train_data, trainloader, validloader, testloader = load_data(data_dir_in)

model = getattr(models, arch_in)(pretrained=True)
for param in model.parameters():
    param.requires_grad = False

build_model(model, hidden_size)

train_model(model, gpu_on, trainloader, validloader, lr_in, epochs)

test_model(model, gpu_on, testloader)

save_model(model, arch_in, train_data, save_dir_in)
def api_keys():
	api_keys = load_data('api_keys.yaml')
	return render_template('api_keys.html',api_keys=api_keys)
def api_docs():
	api = load_data('api.yaml')
	return render_template('api_docs.html',api=api)
Esempio n. 4
0
from keras.models import Sequential
from keras.layers import Dense
import numpy as np
import funcs
from collections import Counter

if __name__ == '__main__':
    print('Getting data')
    # data_train, label_train = funcs.get_train_data()
    data_train = funcs.load_data("INPUT_DATA.pkl")
    label_train = funcs.load_data("INPUT_LABELS.pkl")
    print("len of train " + str(len(data_train)))
    print("len of lable " + str(len(label_train)))
    print("===========================")
    # # Provide Input Data
    # # ========================================================
    # input_data = []
    # for data_item in data_train:
    #     mean = np.mean(data_item)
    #
    #     dt = Counter(data_item)
    #     ent = np.zeros(129)
    #     ent[0] = mean
    #     for idx in range(1,128):
    #         ent[idx] = dt[idx]
    #     input_data.append(ent)
    # input_data = np.asarray(input_data)
    # # print(len(input_data))
    # # print(input_data[0])
    # # exit()
Esempio n. 5
0
bin_width_ms = 1
bin_width_ms_session = 50 
smooth_sd_ms = 100
fr_convert = 1000
trial_duration = 2000
bin_edges_trial = np.arange(0 ,trial_duration, bin_width_ms)
max_list = []
cluster_list = [] 
start_trial_list = []
end_trial_list = []
spikes_times_session_list =[]
for recording_to_extract,session in zip(recordings_to_extract_hp,sessions_hp):cluster_list
    path_to_data = '/'.join([kilosort_folder, recording_to_extract])
    os.chdir(path_to_data)
    ephys_session = fu.load_data(recording_to_extract,kilosort_folder,'/',True )
    beh_session = di.Session('/media/behrenslab/90c50efc-05cf-4045-95e4-9dabd129fb47/Ephys_Reversal_Learning/data/Reversal_learning Behaviour Data and Code/data_3_tasks_ephys/{}'.format(session))
    forced_trials = beh_session.trial_data['forced_trial']
    non_forced_array = np.where(forced_trials == 0)[0]
    task = beh_session.trial_data['task']
    task_non_forced = task[non_forced_array]
    
    #Trial Initiation Timestamps
    pyControl_choice = [event.time for event in beh_session.events if event.name in ['choice_state']]
    pyControl_choice = np.array(pyControl_choice)
    pyControl_end_trial = [event.time for event in beh_session.events if event.name in ['inter_trial_interval']][2:] #first two ITIs are free rewards
    pyControl_end_trial = np.array(pyControl_end_trial)
    task = beh_session.trial_data['task']
    task_1_end_trial = np.where(task == 1)[0]
    task_2_end_trial = np.where(task == 2)[0]
    task_2_change = np.where(task ==2)[0]
    table.write(4, 6, 'k_minus:' + str(k_alpha_minus))
    table.write(5, 6, 'PINC:' + str(PINC))

    # clear current error times
    current_error_times = 0

    # select data set
    [file_name, sheet_name, col, row_start, seq_len,
     interval] = dataset.select_dataset_windpower8_boundvmd(flag)

    # preprocess data
    print('> Loading data... ')
    [X_train, Y_train, X_test, Y_test] = fc.load_data(file_name,
                                                      type='excel',
                                                      sheet_name=sheet_name,
                                                      pre_seq_len=timesteps,
                                                      row=row_start - 1,
                                                      col=col - 1,
                                                      seq_len=seq_len,
                                                      interval=interval)
    # normalization
    [x_train, x_maxmin] = fc.maponezero(X_train)
    [y_train, y_maxmin] = fc.maponezero(Y_train)
    x_test = fc.maponezero(X_test, "apply", x_maxmin)
    y_test = fc.maponezero(Y_test, "apply", y_maxmin)
    x_train = np.reshape(x_train, (x_train.shape[0], x_train.shape[1], 1))
    x_test = np.reshape(x_test, (x_test.shape[0], x_test.shape[1], 1))
    for times in range(0, exp_times):
        while True:
            width_upper_history = []
            width_lower_history = []
            alpha_history = []