'Inh_Gl':10., 'Inh_Cm':200.,'Inh_Trefrac':3., 'Inh_El':-60., 'Inh_Vthre':-53., 'Inh_Vreset':-60., 'Inh_deltaV':0., 'Inh_a':0., 'Inh_b': 0., 'Inh_tauw':1e9, } if sys.argv[-1]=='plot': # ###################### # ## ----- Plot ----- ## # ###################### data = np.load('tf_data.npy', allow_pickle=True).item() ntwk.make_tf_plot_2_variables(data, xkey='F_Exc', ckey='F_Inh', ylim=[1e-1, 100], yticks=[0.1, 1, 10], yticks_labels=['0.01', '0.1', '1', '10'], ylabel='$\\nu_{out}$ (Hz)', xticks=[0.1, 1, 10], xticks_labels=['0.1', '1', '10'], xlabel='$\\nu_{e}$ (Hz)') ntwk.show() else: Model['filename'] = 'tf_data.npy' Model['NRN_KEY'] = 'Exc' # we scan this population Model['tstop'] = 10000 Model['N_SEED'] = 3 # seed repetition Model['POP_STIM'] = ['Exc', 'Inh'] Model['F_Exc_array'] = np.logspace(-1, 2, 40) Model['F_Inh_array'] = np.logspace(-1, 2, 10) ntwk.generate_transfer_function(Model) print('Results of the simulation are stored as:', 'tf_data.npy') # print('--> Run \"python 3pop_model.py plot\" to plot the results')
def main(): try: week = [ 'понедельник', 'вторник', 'среда', 'четверг', 'пятница', 'суббота', 'воскресенье' ] for event in longpoll.listen(): if event.type == VkBotEventType.MESSAGE_NEW: if event.from_chat: id = event.chat_id add_id(id) create_table() msg = event.object.message['text'].lower() if msg[0] == '!': msg = msg[1:] if msg == 'показать расписание': sender(id, 'Введите день недели') f = 'show' if msg in week and f == 'show': ms = '' if msg == 'среда': ms = 'среду' elif msg == 'пятница': ms = 'пятницу' elif msg == 'суббота': ms = 'субботу' else: ms = msg sender( id, 'Расписание на {}: \n{}'.format( ms, show(id, week.index(msg)))) if msg == 'изменить расписание': sender(id, 'Введите день недели') f = 'change' if msg in week and f == 'change': sender(id, 'Вводите уроки (каждый с новой строки)') day = msg f = 'add' if f == 'add': rasp = msg.split() change(id, week.index(day), rasp) da = '' if day == 'среда': da = 'среду' elif day == 'пятница': da = 'пятницу' elif day == 'суббота': da = 'субботу' else: da = day if len(rasp) > 1: sender( id, "Расписание на {} обновлено✅ ".format(da)) except: main()
def evaluate(args): device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') print(device) data = DataSet() args.vocab_size = len(data.char2int) args.embedding_size = 256 #len(data.char2int)#128 args.classes = len(data.languages) args.num_hidden = 64 model = VolapukModel( vocab_size=args.vocab_size, embed_size=args.embedding_size, num_output=args.classes, hidden_size=args.num_hidden, num_layers=args.num_layers, batch_first=True, importance_sampler=args.importance_sampler).to(device=device) print('\n\n', args.importance_sampler) # if args.load_model: try: print(f'Load model {args.load_PATH}.p') model.load_state_dict( torch.load(f'{args.load_PATH}.p', map_location=device)) except FileNotFoundError: print('please include path') return correct_dict = { data.lan2int[lan]: torch.zeros(len(data.languages)) for lan in data.languages } total_dict = { data.lan2int[lan]: torch.zeros(len(data.languages)) for lan in data.languages } criterion = nn.CrossEntropyLoss() optimizer = optim.SGD(model.parameters(), lr=args.learning_rate, momentum=args.momentum) temp_batch_size = args.batch_size losses = [] accuracies = [] steps = [] model.eval() for i in tqdm(range(args.training_steps)): # Get batch and targets, however not in correct format batch, targets = data.get_next_test_batch(args.batch_size) list_of_one_hot_X = [] # Convert batch to X y = [] languages = list(data.languages) # print(data.languages) for par, target in zip(batch, targets): # We cutoff to only use the final 140 characters at the end. # This is done, as the first will have a lot of meaningless information, such as pronunciaton # This way it is easier for the batches to be read, as well as the bias for the length of the text to be removed. par = par[-140:] x = [] for char in par: try: x.append(data.char2int[char]) except: x.append(data.char2int['☃']) x_tensor = torch.tensor(x).type(torch.LongTensor).view(-1, 1) list_of_one_hot_X.append(x_tensor) y.append(languages.index(target)) X = torch.stack(list_of_one_hot_X, dim=0).squeeze() Y = torch.tensor(y).type(torch.LongTensor).view(-1, 1).squeeze() args.batch_size = Y.shape[0] X = X.to(device) Y = Y.to(device) test_batch, test_targets = data.get_next_test_batch(args.batch_size) test_X, test_Y = main.get_X_Y_from_batch(test_batch, test_targets, data, device) test_out, test_mask, test_mask_loss = model.forward( test_X, (torch.ones(args.batch_size) * args.batch_size).long()) acc, correct_dict, total_dict = accuracy(test_out, Y, correct_dict, total_dict) main.show(test_X, test_mask, test_Y, data) lan2language = {} with open('../data/wili-2018/labels.csv', 'r') as f: csv_reader = csv.reader(f, delimiter=';') line_count = 0 for row in csv_reader: if line_count == 0: print(f'Column names are {", ".join(row)}') line_count += 1 else: if row[1] == 'Swahili (macrolanguage)': lan2language[row[0]] = 'Swahili' continue lan2language[row[0]] = row[1] acc_per_lan = {} for lan in data.languages: acc_per_lan[lan2language[lan]] = ( total_dict[data.lan2int[lan]] / correct_dict[data.lan2int[lan]]).mean().item() print(acc_per_lan) # baseline_acc_per_lan = baseline.unigram_baseline(args) # barplot_languages(acc_per_lan, baseline_acc_per_lan) # barplot_languages(acc_per_lan, baseline_acc_per_lan, acc_per_lan) # plot_languages(acc_per_lan) return acc_per_lan #, baseline_acc_per_lan
import main # import DictionaryReader # # dict = DictionaryReader.reading('/home/rpalamut/dataless.txt') # for i in dict: # print dict[i]['group'] # print dict[i]['geo'] main.show(2000)
for cwd, folders, files in os.walk(root): for fname in files: # os.path.splitext splits a filename into a tuple like so: # (file_path, extension) if os.path.splitext(fname)[1] in self.extensions: # key = filename, value = directory of file rv.append(fname) if len(rv) == 0: for root in roots: if os.path.splitext(root)[1] in self.extensions: rv.append(root.split("/")[-1]) return rv extensions = [".3g2", ".3gp", ".asf", ".asx", ".avi", ".flv", ".m4v", ".mov", ".mp4", ".mpg", ".rm", ".swf", ".vob", ".wmv", ".aepx", ".ale", ".avp", ".avs", ".bdm", ".bik", ".bin", ".bsf", ".camproj", ".cpi", ".dash", ".divx", ".dmsm", ".dream", ".dvdmedia", ".dvr-ms", ".dzm", ".dzp", ".edl", ".f4v", ".fbr", ".fcproject", ".hdmov", ".imovieproj", ".ism", ".ismv", ".m2p", ".mkv", ".mod", ".moi", ".mpeg", ".mts", ".mxf", ".ogv", ".otrkey", ".pds", ".prproj", ".psh", ".r3d", ".rcproject", ".rmvb", ".scm", ".smil", ".snagproj", ".sqz", ".stx", ".swi", ".tix", ".trp", ".ts", ".veg", ".vf", ".vro", ".webm", ".wlmp", ".wtv", ".xvid", ".yuv", ".3gp2", ".3gpp", ".3p2", ".890", ".aaf", ".aec", ".aep", ".aetx", ".ajp", ".amc", ".amv", ".amx", ".arcut", ".arf", ".avb", ".avchd", ".avv", ".axm", ".bdmv", ".bdt3", ".bmc", ".bmk", ".camrec", ".ced", ".cine", ".cip", ".clpi", ".cmmp", ".cmmtpl", ".cmproj", ".cmrec", ".cst", ".d2v", ".d3v", ".dat", ".dce", ".dck", ".dcr", ".dcr", ".dir", ".dmsd", ".dmsd3d", ".dmss", ".dmx", ".dpa", ".dpg", ".dv", ".dv-avi", ".dvr", ".dvx", ".dxr", ".dzt", ".evo", ".eye", ".eyetv", ".ezt", ".f4p", ".fbz", ".fcp", ".ffm", ".flc", ".flh", ".fli", ".fpdx", ".ftc", ".gcs", ".gfp", ".gifv", ".gts", ".hdv", ".hkm", ".ifo", ".imovieproject", ".ircp", ".ismc", ".ivr", ".izz", ".izzy", ".jss", ".jts", ".jtv", ".kdenlive", ".lrv", ".m1pg", ".m21", ".m21", ".m2t", ".m2ts", ".m2v", ".mani", ".mgv", ".mj2", ".mjp", ".mk3d", ".mnv", ".mp21", ".mp21", ".mpgindex", ".mpl", ".mpls", ".mproj", ".mpv", ".mqv", ".msdvd", ".mse", ".mswmm", ".mtv", ".mvd", ".mve", ".mvp", ".mvp", ".mvy", ".mxv", ".ncor", ".nsv", ".nuv", ".nvc", ".ogm", ".ogx", ".pac", ".pgi", ".photoshow", ".piv", ".plproj", ".pmf", ".ppj", ".prel", ".pro", ".prtl", ".pxv", ".qtl", ".qtz", ".rcd", ".rdb", ".rec", ".rmd", ".rmp", ".rms", ".roq", ".rsx", ".rum", ".rv", ".rvid", ".rvl", ".sbk", ".scc", ".screenflow", ".sdv", ".sedprj", ".seq", ".sfvidcap", ".siv", ".smi", ".smi", ".smk", ".stl", ".svi", ".swt", ".tda3mt", ".thp", ".tivo", ".tod", ".tp", ".tp0", ".tpd", ".tpr", ".trec", ".tsp", ".ttxt", ".tvlayer", ".tvs", ".tvshow", ".usf", ".usm", ".vbc", ".vc1", ".vcpf", ".vcv", ".vdo", ".vdr", ".vep", ".vfz", ".vgz", ".viewlet", ".vlab", ".vp6", ".vp7", ".vpj", ".vsp", ".wcp", ".wmd", ".wmmp", ".wmx", ".wp3", ".wpl", ".wve", ".wvx", ".xej", ".xel", ".xesc", ".xfl", ".xlmv", ".y4m", ".zm1", ".zm2", ".zm3", ".zmv", ".264", ".3gpp2", ".3mm", ".60d", ".aet", ".anx", ".avc", ".avd", ".avs", ".awlive", ".axv", ".bdt2", ".bnp", ".box", ".bs4", ".bu", ".bvr", ".byu", ".camv", ".clk", ".cx3", ".dav", ".ddat", ".dif", ".dlx", ".dmb", ".dmsm3d", ".dnc", ".dv4", ".f4f", ".fbr", ".ffd", ".flx", ".gvp", ".h264", ".inp", ".int", ".irf", ".iva", ".ivf", ".jmv", ".k3g", ".ktn", ".lrec", ".lsx", ".lvix", ".m1v", ".m2a", ".m4u", ".meta", ".mjpg", ".modd", ".moff", ".moov", ".movie", ".mp2v", ".mp4.infovid", ".mp4v", ".mpe", ".mpl", ".mpsub", ".mvc", ".mvex", ".mys", ".osp", ".par", ".playlist", ".pns", ".pro4dvd", ".pro5dvd", ".proqc", ".pssd", ".pva", ".pvr", ".qt", ".qtch", ".qtindex", ".qtm", ".rp", ".rts", ".sbt", ".scn", ".sfd", ".sml", ".smv", ".spl", ".str", ".tdt", ".tid", ".tvrecording", ".vcr", ".vem", ".vft", ".vfw", ".vid", ".video", ".vix", ".vs4", ".vse", ".w32", ".wm", ".wot", ".xmv", ".yog", ".787", ".am", ".anim", ".aqt", ".bix", ".cel", ".cvc", ".db2", ".dsy", ".gl", ".gom", ".grasp", ".gvi", ".ismclip", ".ivs", ".kmv", ".lsf", ".m15", ".m4e", ".m75", ".mmv", ".mob", ".mpeg1", ".mpeg4", ".mpf", ".mpg2", ".mpv2", ".msh", ".mvb", ".nut", ".orv", ".pjs", ".pmv", ".psb", ".rmd", ".rmv", ".rts", ".scm", ".sec", ".ssf", ".ssm", ".tdx", ".vdx", ".viv", ".vivo", ".vp3", ".zeg"] def newWindow(self, names): self.hide() import main self.form2 = main.MainWindow(files=names) self.form2.show() if __name__ == "__main__": app = QtGui.QApplication(sys.argv) main = droppableWidget() main.show() sys.exit(app.exec_())