def bewaesserungsablauf(rtClock, mcp, cfgData, data, dt): """ Führt die Messungen durch und speichert die Werte in der JSON-Datenstruktur. Dann prüft er ob die Voraussetzungen für eine Bewässerung vorliegen und startet ggf. die Bewässerungsroutine. Schließlich wird noch die JSON-Datenstruktur sowie die Konfigurationsdatei gespeichert und der nächste Startzeitpunkt bestimmt und in die RTC geschrieben Parameter rtClock: Instanz des RTC-Objekts mcp: Instanz des MCP3008-Objekts (Analog-Digital-Konverter) data: JSON-Datenobjekt dt: Datum-Uhrzeit-Objekt mit dem Timestamp des Starts """ rlib.sensordaten_auslesen(rtClock, mcp, data) # Bewässerungslogik startet if cfgData['Bewaesserung_aktiv']: if dt.hour in cfgData['Bewaesserungsstunden']: bf = rlib.bodenfeuchtigkeit_messen(mcp) if bf[0] > cfgData['Grenzwert_Bodenfeuchtigkeit']: if cfgData['Anzahl_kein_Wasser'] <= 2: logger.info("Bewässerung kann starten") r = res.Reservoir(18,0,1,2,15) ret = r.fuelleBisLevel(ZIELLEVEL) if ret==ZIELLEVEL: logger.info("Reservoir konnte auf Ziellevel {:} gefüllt werden".format(ZIELLEVEL)) cfgData['Anzahl_kein_Wasser'] = 0 else: logger.info("Füllung Reservoir nur bis Level {:} statt {:} möglich".format(ret, ZIELLEVEL)) cfgData['Anzahl_kein_Wasser'] = cfgData['Anzahl_kein_Wasser'] + 1 logger.info("Wert von Anzahl_kein_Wasser: {:}".format(cfgData['Anzahl_kein_Wasser'])) else: logger.info("Abbruch da bei den letzten beiden Versuchen kein Wasser verfügbar war") else: logger.info("Abbruch Bodensensor zeigt genügend Feuchtigkeit an ({:}/Grenzwert {:})".format(bf[0], cfgData['Grenzwert_Bodenfeuchtigkeit'])) else: logger.info("keine Uhrzeit für Bewässerung") else: logger.info("Bewässerung ist nicht aktiviert") # Jetzt noch die Daten speichern und RTC auf nächsten Startzeitpunkt programmieren lib.save_json(cfgData, data) rlib.naechsten_start_bestimmen(rtClock)
skip = 0 size = 160 scale = 16 length = 10000000 max_init = 100 take = int(sys.argv[1]) np.random.seed(take) rndweight = tb.rndWeights(size) # first command to use rnd to keep track maxAbsEigVal = tb.findMaxAbsEigVal(rndweight) weight = (scale * rndweight) / maxAbsEigVal file = open("./data/output/160-16-9/" + str(take) + ".txt", "w+") np.random.seed(100101) for initid in range(max_init): print("take:", take, "initid:", initid) state = tb.unitState(size) * 0.5 r = res.Reservoir(size, weight, state) r.run(transient, mode="transient") r.run(length, mode="extract", skip=skip) ostr = "".join(r.output) file.write(ostr) file.close()
import RPi.GPIO as GPIO import reservoir as res import time import logging try: GPIO.setmode(GPIO.BOARD) w = res.Reservoir(18, 0, 1, 2, 15) # w.pumpe("on") # time.sleep(10) # w.pumpe("off") # time.sleep(10) # w.pumpe("on") # time.sleep(10) # w.pumpe("off") while True: print("{:} Wasserstand => {:}".format(time.strftime("%Y%m%d_%H%M%S"), w.gibStand())) time.sleep(2) # Programm beenden except KeyboardInterrupt: logger.exception("Programm abgebrochen") #except: # this catches ALL other exceptions including errors. # You won't get any error messages for debugging # so only use it once your code is working #print ("Other error or exception occurred!" )
inputpop = pyNCS.Population('', '') inputpop.populate_by_id(nsetup, 'mn256r1', 'excitatory', np.linspace(0, 255, 256)) #reset multiplexer bioamp = Bioamp(inputpop) bioamp._init_fpga_mapper() #######################################################3 #### RESERVOIR ######################################################## rcnpop = pyNCS.Population('neurons', 'for fun') rcnpop.populate_all(nsetup, 'mn256r1', 'excitatory') res = L.Reservoir(rcnpop, cee=0.4, cii=0.2) #0.8 0.6 if (load_config == True): res.load_config(config_dir) res.program_config() res.reset(alpha=np.logspace(-10, 100, 500)) ##init regressor ################################ ### CONNECT BIOAMP TO RESERVOIR ################################ bioamp._init_fpga_mapper() bioamp.map_bioamp_reservoir_broadcast(n_columns=4) nsetup.mapper._program_detail_mapping(2**3 + 2**4) print( 'load parameters from bioamp interface.. use file biases/bioamp_delta_reservoir.txt or biases/bioamp_delta_reservoir_forest.txt'
CO = np.dot(Y.T, Y) CI = np.dot(X.T, X) si = np.linalg.svd(CI, full_matrices=True, compute_uv=False) so = np.linalg.svd(CO, full_matrices=True, compute_uv=False) semilogy(so / so[0], 'bo-', label="outputs") semilogy(si / si[0], 'go-', label="inputs") xlabel('Singular Value number') ylabel('value') legend(loc="best") ###################################### # LOAD DATA and DO EVERYTHING OFFLINE ###################################### res = L.Reservoir( ) #object without population does not need the chip offline build fig_a = figure() fig_all_train = figure() rmse_tot = np.zeros([nScales, num_gestures, repeat_same]) rmse_tot_input = np.zeros([nScales, num_gestures, repeat_same]) #### TRAIN for this_g in range(num_gestures): teach_sig = np.zeros([nT, nScales]) for this_te in range(nScales): teach_sig[:, this_te] = np.loadtxt(directory + "teaching_signals_gesture_" + str(this_g) + "_teach_input_" + str(this_te) + "_trial_" + str(0) +
def main(path_file_in, path_file_out, N=800, sr=3, iss=0.1, leak=0.1, ridge=10**-1, plot=False, feedback=False, return_result=False, verbose=False): def write_list_in_file(l, file=None, file_path=None): """ Write a list in a file with with one item per line (like a one column csv). If file is given, then it assumes the file is already open for writing. If file_path is given, then it opens the file for writing, write the list, and then close the file. """ if file_path is not None: if file is not None: raise Exception, "Too much arguments. You must choose between file and file_path." else: file = open(file_path, 'w') if file is None: raise Exception, "No file given in input." for item in l: file.write("%s\n" % item) if file_path is not None: file.close() import io_language_coding as CtIolangcod sentence_to_meaning = False # Definning parameters of stimulus (in a dictionary) d = {} d['act_time'] = 5 d['pause'] = True d['suppl_pause_at_the_end'] = 1 * d['act_time'] d['initial_pause'] = True d['offset'] = False ## Random parameters import time millis = int(round(time.time())) seed = millis #2#4#2 if seed is not None: mdp.numx.random.seed(seed) np.random.seed(seed) [train_data_txt, test_data_txt, sent_form_info_train, sent_form_info_test] = extract_data_io(path_file=path_file_in) train_corpus, train_meaning = txt2corpus_and_meaning( train_txt=train_data_txt) if sentence_to_meaning: test_corpus = test_data_txt else: test_meaning = test_data_txt # making the list of constructions (refering to "construction grammar"), a construction is a sentence without its open class words (Nouns and Verbs) (l_construction_train, construction_words) = get_and_remove_ocw_in_corpus(corpus=train_corpus, _OCW='X') l_ocw_array_train = generate_l_ocw_array(sent_form_info_train, train_meaning) l_ocw_array_test = generate_l_ocw_array(sent_form_info_test, test_meaning) #print "**************************" #print "l_construction_train", l_construction_train #print "construction words", construction_words if sentence_to_meaning: (l_construction_test, construction_words_test) = get_and_remove_ocw_in_corpus( corpus=test_corpus, _OCW='X') #print "l_construction_test", l_construction_test if construction_words != construction_words_test: raise Exception, "The construction words are not the same for the train constructions and the test constructions. So the coding of sentences will be different and should provoque a future problem." ## Generating all the sentence stimulus (in order to have the same length for each sentence) if sentence_to_meaning: ## Generate the stimulus input for train and test data l_full_const = l_construction_train + l_construction_test slice_test = slice( len(l_construction_train), len(l_construction_train) + len(l_construction_test)) else: l_full_const = l_construction_train slice_train = slice(0, len(l_construction_train)) (stim_full_data, l_full_offset) = CtIolangcod.generate_stim_input_nodic( l_data=l_full_const, # act_time=d['act_time'], subset=None, l_input=None, act_time=d['act_time'], subset=None, l_input=construction_words, l_nr_word=None, mult=None, full_time=None, with_offset=d['offset'], pause=d['pause'], initial_pause=d['initial_pause'], suppl_pause_at_the_end=d['suppl_pause_at_the_end'], verbose=False) stim_sent_train = stim_full_data[slice_train] if sentence_to_meaning: stim_sent_test = stim_full_data[slice_test] l_m_elt = get_meaning_coding() (stim_mean_train, l_meaning_code_train) = generate_meaning_stim( l_structure=sent_form_info_train, full_time=stim_sent_train[0].shape[0], l_m_elt=l_m_elt) if not sentence_to_meaning: #print "*** Generating meaning for test set ... ***" (stim_mean_test, l_meaning_code_test) = generate_meaning_stim( l_structure=sent_form_info_test, full_time=stim_sent_train[0].shape[0], l_m_elt=l_m_elt) other_corpus_used = False # Reservoir and Read-out definitions res = reservoir.Reservoir(N, sr, iss, leak) #classic working of the reservoir if feedback == False: ## test set = train set states_out_train, internal_states_train = res.train( stim_mean_train, stim_sent_train) ## test set not train set states_out_test, internal_states_test = res.test(stim_mean_test) #feedback working of the reservoir. !! Should be implemented directly in the reservoir class !! else: delay = 1 nb_epoch_max = 4 dim_input = stim_mean_train[0].shape[1] dim_output = len(stim_sent_train[0][0]) input_train = [] for (x, y) in zip(np.copy(stim_mean_train), np.copy(stim_sent_train)): for time_step_delay in range(delay): y = np.concatenate(([[0.] * len(y[0])], y), axis=0) input_train.append( np.array(np.concatenate((x, y[:-delay]), axis=1))) nb_train = 0 while nb_train < nb_epoch_max: ## test set = train set states_out_train, internal_states_train = res.train( input_train, stim_sent_train) tab_feedback = [] for num_phrase in range(len(states_out_train)): #signal tresholded states_out_train[num_phrase] = np.array([ treshold_signal(signal_t, 1.5, -0.5) for signal_t in states_out_train[num_phrase] ]) if nb_train == 0: #feedback kept only for the first train #feedback assignation feedback = np.array(states_out_train[num_phrase]) #signal delayed for time_step_delay in range(delay): feedback = np.concatenate( ([[0.] * len(feedback[0])], feedback), axis=0) tab_feedback.append(feedback) input_train[num_phrase] = input_train[num_phrase].T input_train[num_phrase][dim_input:] = feedback[:-delay].T input_train[num_phrase] = input_train[num_phrase].T nb_train += 1 ## test set not train set for t in range(0, stim_mean_test[0].shape[0], 1): input_test = [] if t == 0: #A REMODIFIER for n_phrase in range(len(stim_mean_test)): input_test.append( np.concatenate((stim_mean_test[n_phrase][t:t + 1, :], [[0.] * len(stim_sent_train[0][0])]), axis=1)) states_out_test, internal_states_test = res.test(input_test) import copy states_out_test_def = copy.deepcopy(states_out_test) else: for n_phrase in range(len(stim_mean_test)): #feedback assignation feedback = np.array(states_out_test[n_phrase]) input_test.append( np.concatenate( (stim_mean_test[n_phrase][t:t + 1, :], feedback), axis=1)) states_out_test, internal_states_test = res.test(input_test) for n_phrase in range(len(stim_mean_test)): states_out_test_def[n_phrase] = np.concatenate( (states_out_test_def[n_phrase], states_out_test[n_phrase]), axis=0) states_out_test = states_out_test_def # Ecriture de la phrase de réponse if other_corpus_used: var_inutile = 0 else: l_recovered_construction_train = convert_l_output_activity_in_construction( l_out_act=states_out_train, construction_words=construction_words, min_nr_of_val_upper_thres=1) l_recovered_sentences_train = attribute_ocw_to_constructions( l_constructions=l_recovered_construction_train, l_ocw_array=l_ocw_array_train, _OCW='X') l_recovered_construction_test = convert_l_output_activity_in_construction( l_out_act=states_out_test, construction_words=construction_words, min_nr_of_val_upper_thres=2) l_recovered_sentences_test = attribute_ocw_to_constructions( l_constructions=l_recovered_construction_test, l_ocw_array=l_ocw_array_test, _OCW='X') ## Writting sentences to output file #print " *** Writting to output file ... *** " l_final_sent_test = [] for list_words in l_recovered_sentences_test: l_final_sent_test.append(" ".join(list_words)) #print " *** ... Writting done ***" #print "**********************************************" print "********************************************** " print " *** RECOGNIZED SENTENCES *** " print l_final_sent_test[0] write_list_in_file(l=l_final_sent_test, file_path=path_file_out) if return_result: return l_final_sent_test ## Plot inputs if plot: import plotting as plotting plotting.plot_array_in_file( root_file_name="../Results/states_out_train", array_=states_out_train, titles_subset=l_construction_train, legend_=construction_words, plot_slice=None, title="", subtitle="") plotting.plot_array_in_file( root_file_name="../Results/states_out_test", array_=states_out_test, titles_subset=l_recovered_sentences_test, legend_=construction_words, plot_slice=None, title="", subtitle="") print ""
prefix = '../' setuptype = '../setupfiles/mc_final_mn256r1.xml' setupfile = '../setupfiles/final_mn256r1_retina_monster.xml' nsetup = pyNCS.NeuroSetup(setuptype, setupfile, prefix=prefix) nsetup.mapper._init_fpga_mapper() chip = nsetup.chips['mn256r1'] chip.configurator._set_multiplexer(0) #populate neurons rcnpop = pyNCS.Population('neurons', 'for fun') rcnpop.populate_by_id(nsetup, 'mn256r1', 'excitatory', neuron_ids) #init liquid state machine print "################# init onchip recurrent connections... [reservoir] " res = L.Reservoir(rcnpop, cee=0.6, cii=0.35) #c = 0.2 #dim = np.round(np.sqrt(len(liquid.rcn.synapses['virtual_exc'].addr)*c)) chip.load_parameters('biases/biases_reservoir_amplitude.biases') # do config only once is_configured = True c = 0.013 duration = 250 delay_sync = 550 max_freq = 385 min_freq = 5 nsteps = 25 freq_sync = 1000
"idx":idx,\ "idx_spk":idx_spk,\ "W_train":W_train,\ "W_test":W_test}) else: tmp = loadmat("cut_data.mat") X_train = tmp["X_train"] W_train = tmp["W_train"] X_test = tmp["X_test"] W_test = tmp["W_test"] t_analog = tmp["t_analog"] idx = tmp["idx"][0] del tmp ## Reservoir res = L.Reservoir() # Frequency scaling of teaching signal base_freq = 1.2 * np.pi / 1e3 # MHz delt_freq = base_freq * 0.1 # MHz # Teaching signal T_sig = lambda t,w: np.mean( \ np.sin((base_freq+delt_freq*w)*t),\ axis=1)[:,None] print "#### TEACHING" ## Update readout weights for i in xrange(n_teach): #build teaching signal
def train(self, sent_form_info_train, train_meaning, train_corpus, d, sr=3, iss=0.1, leak=0.1, ridge=10**-1): import io_language_coding as CtIolangcod ## Random parameters import time millis = int(round(time.time())) seed = millis #2#4#2 if seed is not None: mdp.numx.random.seed(seed) np.random.seed(seed) # making the list of constructions (refering to "construction grammar"), a construction is a sentence without its open class words (Nouns and Verbs) (l_construction_train, construction_words) = self.get_and_remove_ocw_in_corpus( corpus=train_corpus, _OCW='X') l_ocw_array_train = self.generate_l_ocw_array(sent_form_info_train, train_meaning) l_full_const = l_construction_train slice_train = slice(0, len(l_construction_train)) ( stim_full_data, l_full_offset ) = CtIolangcod.generate_stim_input_nodic( l_data=l_full_const, # act_time=d['act_time'], subset=None, l_input=None, act_time=d['act_time'], subset=None, l_input=construction_words, l_nr_word=None, mult=None, full_time=None, with_offset=d['offset'], pause=d['pause'], initial_pause=d['initial_pause'], suppl_pause_at_the_end=d['suppl_pause_at_the_end'], verbose=False) stim_sent_train = stim_full_data[slice_train] l_m_elt = self.get_meaning_coding( max_nr_ocw=self.imax_nr_ocw, max_nr_actionrelation=self.imax_nr_actionrelation, elt_pred=self.l_elt_pred) (stim_mean_train, l_meaning_code_train) = self.generate_meaning_stim( l_structure=sent_form_info_train, full_time=stim_sent_train[0].shape[0], l_m_elt=l_m_elt) # Reservoir and Read-out definitions res = reservoir.Reservoir(self.iNbNeurons, sr, iss, leak) #classic working of the reservoir without feedback ## test set = train set states_out_train, internal_states_train = res.train( stim_mean_train, stim_sent_train) return l_ocw_array_train, states_out_train, construction_words, internal_states_train, res, stim_mean_train, stim_sent_train, l_m_elt
def main(): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--in_size', '-i', type=int, help='input size', default=1) parser.add_argument('--res_size', '-r', type=int, help='reservoir size', default=100) parser.add_argument('--out_size', '-o', type=int, help='output size', default=1) parser.add_argument('--con', '-c', type=float, help='connectivity range:0~1', default=0.05) #parser.add_argument('--make', type=int, help='random weight make Yes:-1(default), No:0', default=-1) parser.add_argument('--dataset', '-d', type=str, help='dataset name', default='MG', choices=['MG']) parser.add_argument('--data_len', '-l', type=int, help='dataset length', default=2000) parser.add_argument( '--folder', '-f', type=str, help='output folder name (default: nowtime)', default=datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')) parser.add_argument('--topology', '-t', type=str, help='select topology', default='random', choices=['random', 'ring', 'center', 'ring_center']) #for chainer parser.add_argument('--epoch', '-e', type=int, default=100, help='Number of sweeps over the dataset to train') parser.add_argument('--batchsize', '-b', type=int, default=100, help='Number of images in each mini-batch') parser.add_argument('--frequency', type=int, default=-1, help='Frequency of taking a snapshot') parser.add_argument('--gpu', '-g', type=int, default=-1, help='GPU ID (negative value indicates CPU)') parser.add_argument('--resume', default='', help='Resume the training from snapshot') parser.add_argument('--noplot', dest='plot', action='store_false', help='Disable PlotReport extension') args = parser.parse_args() args.folder = '{}'.format(args.folder) os.mkdir(args.folder) ''' print('[args]') f = open('{}/args.csv'.format(args.folder),'w') for key,item in vars(args).items(): print('{}:{}'.format(key,item)) f.write('{}\t{}'.format(key,item)) f.close() ''' # make_input_dataset print('make dataset') if args.dataset == 'MG': input_train = datasets.Mackey_Glass_equation(1.2, args.data_len, args.in_size) input_test = datasets.Mackey_Glass_equation(0.2, args.data_len, args.in_size) else: print('no dataset') sys.exit() # set_reservoir print('set reservoir') rsv = reservoir.Reservoir(args.folder, args.in_size, args.res_size, args.con, args.topology) # run_train_reservoir print('make x_train') x_train, flow_train = rsv.run(input_train, args.data_len) ''' with open('{}/reservoir_flow_train.pickle'.format(args.folder), mode='wb') as f: pickle.dump(flow_train, f) ''' # run_test_reservoir print('make x_test') x_test, flow_test = rsv.run(input_test, args.data_len) ''' with open('{}/reservoir_flow_test.pickle'.format(args.folder), mode='wb') as f: pickle.dump(flow_test, f) ''' #np.savez('{}/dataset{}.npz'.format(args.folder,args.dataset),train_input=input_train,test_input=input_test,train_reservoir=x_train,test_reservoir=x_test) # cut_begin_traindata and reshape for chainer model print('arrange datasets for chainer') cut = 100 input_train_cut = input_train.reshape(args.data_len, args.in_size)[cut + 1:-1] x_train_cut = x_train.reshape(args.data_len, args.res_size)[cut:-2] input_test_cut = input_test.reshape(args.data_len, args.in_size)[cut + 1:-1] x_test_cut = x_test.reshape(args.data_len, args.res_size)[cut:-2] print('[learning]') readout.main(args, [x_train_cut, input_train_cut], [x_test_cut, input_test_cut]) print('draw compare graph') snapshot = np.load('{}/snapshot.npz'.format(args.folder)) Wout = snapshot['updater/model:main/predictor/l1/W'] b = snapshot['updater/model:main/predictor/l1/b'] compare.fig(input_train, x_train, Wout, b, args.folder, 'train') compare.fig(input_test, x_test, Wout, b, args.folder, 'test')
#setup prefix = '../' setuptype = '../setupfiles/mc_final_mn256r1.xml' setupfile = '../setupfiles/final_mn256r1_retina_monster.xml' nsetup = pyNCS.NeuroSetup(setuptype, setupfile, prefix=prefix) nsetup.mapper._init_fpga_mapper() chip = nsetup.chips['mn256r1'] chip.configurator._set_multiplexer(0) #populate neurons rcnpop = pyNCS.Population('neurons', 'for fun') rcnpop.populate_by_id(nsetup, 'mn256r1', 'excitatory', neuron_ids) #init liquid state machine print "################# init onchip recurrent connections... [reservoir] " res = L.Reservoir(rcnpop, cee=1.0, cii=0.45) res.program_config() #c = 0.2 #dim = np.round(np.sqrt(len(liquid.rcn.synapses['virtual_exc'].addr)*c)) chip.load_parameters('biases/biases_reservoir_synthetic_stimuli.biases') # do config only once is_configured = True ###################################### # End chip configuration ###################################### ###################################### # Gestures and network parameters # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ CUT ######################################
logger = logging.getLogger() logger.setLevel(logging.DEBUG) formatter = logging.Formatter('%(asctime)s | %(levelname)s -> %(message)s') # creating a handler to log on the filesystem file_handler = logging.FileHandler('/home/pi/test_reservoir.log') file_handler.setFormatter(formatter) file_handler.setLevel(logging.DEBUG) # adding handlers to our logger logger.addHandler(file_handler) #creating a handler to log on the console stream_handler = logging.StreamHandler() stream_handler.setFormatter(formatter) stream_handler.setLevel(logging.DEBUG) logger.addHandler(stream_handler) GPIO.setmode(GPIO.BOARD) r = res.Reservoir(18, 0, 1, 2, 16) ret = r.fuelleBisLevel(2) logger.info("Rückgabe: {:}".format(ret)) # while True: # print("{:} Wasserstand => {:}".format(time.strftime("%Y%m%d_%H%M%S"), w.gibStand())) # time.sleep(2) # Programm beenden except KeyboardInterrupt: logger.exception("Programm abgebrochen") #except: # this catches ALL other exceptions including errors. # You won't get any error messages for debugging # so only use it once your code is working
np.linspace(0, 255, 256)) broadcast_pop = pyNCS.Population('', '') broadcast_pop.populate_all(nsetup, 'mn256r1', 'excitatory') #reset multiplexer bioamp = Bioamp(inputpop) bioamp._init_fpga_mapper() #map up,dn channels to chip bioamp.map_bioamp_reservoir_broadcast(n_columns=3) nsetup.mapper._program_detail_mapping(0) #chip.load_parameters('biases/biases_reservoir_synthetic_stimuli.biases') #then load bioamp biases on top of these rcnpop = pyNCS.Population('neurons', 'for fun') rcnpop.populate_all(nsetup, 'mn256r1', 'excitatory') res = L.Reservoir() #offline build ####configure chip matrixes print "configure chip matrixes" matrix_b = np.random.choice([0, 0, 1], [256, 256]) matrix_e_i = np.random.choice([0, 0, 1, 1, 1], [256, 256]) index_w_1 = np.where(matrix_b == 1) matrix_weight = np.zeros([256, 256]) matrix_weight[index_w_1] = 1 index_w_2 = np.where(matrix_weight != 1) matrix_weight[index_w_2] = 2 matrix_recurrent = np.random.choice([0, 0, 1, 1, 1], [256, 256]) matrix_recurrent[index_w_1] = 0 nsetup.mapper._program_onchip_programmable_connections(matrix_recurrent)
import functions sys.path.append('../api/reservoir/') sys.path.append('../api/retina/') sys.path.append('../gui/reservoir_display/') from scipy import interpolate import reservoir as L from perceptrons import Perceptrons from wij import SynapsesLearning from bioamp import Bioamp import time import scipy.signal import subprocess from pyNCS.pyST import SpikeList res = L.Reservoir() #reservoir without configuring the chip ion() figs = figure() prefix = '../' setuptype = '../setupfiles/mc_final_mn256r1_adcs.xml' setupfile = '../setupfiles/final_mn256r1_adcs.xml' nsetup = pyNCS.NeuroSetup(setuptype, setupfile, prefix=prefix) chip = nsetup.chips['mn256r1'] p = pyNCS.Population('', '') p.populate_all(nsetup, 'mn256r1', 'excitatory') inputpop = pyNCS.Population('', '') inputpop.populate_by_id(nsetup, 'mn256r1', 'excitatory', np.linspace(0, 255, 256))
def Reservoir(self): r = reservoir.Reservoir() r.set_limit(10) for i in range(100000): r.pool(i) print(r.get_pool())