def generator_reservoir(self): """ Use another function to create the reservoir and return it """ if self.com_size != None: minc = self.com_size maxc = self.com_size else: minc = self.minc maxc = self.maxc if self.homok != None: k = self.homok maxk = self.homok else: k = self.k maxk = self.maxk self.nx_reservoir = graphgen.uniform_weighted_directed_lfr_graph( N=self.N, mu=self.mu, k=k, maxk=maxk, minc=minc, maxc=maxc, deg_exp=self.deg_exp, temp_dir_ID=self.temp_dir_ID, full_path=self.full_path, weight_bounds=self.reservoir_weight_scale * self.reservoir_weight_bounds) return np.asarray(nx.to_numpy_matrix(self.nx_reservoir))
def generator_reservoir(self): """ Use another function to create the reservoir and return it """ self.nx_reservoir = graphgen.uniform_weighted_directed_lfr_graph( N=self.N, mu=self.mu, k=self.k, maxk=self.maxk, minc=self.minc, maxc=self.maxc, deg_exp=self.deg_exp, temp_dir_ID=self.temp_dir_ID, full_path=self.full_path, weight_bounds=self.reservoir_weight_scale * np.array([self.lower_reservoir_bound, self.upper_reservoir_bound])) reservoir = np.asarray(nx.to_numpy_matrix(self.nx_reservoir)) if self.spectral_factor != None: reservoir = np.asmatrix(reservoir) * np.identity(self.N) effective_spectral_radius = self.calculate_largest_eigenval( reservoir) print effective_spectral_radius reservoir = reservoir / effective_spectral_radius * self.spectral_factor return reservoir
def generate_network(N, mu, k, maxk, minc, maxc, deg_exp, weight_scale, lower_weight_bound, upper_weight_bound, temp_dir_ID, full_path): return graphgen.uniform_weighted_directed_lfr_graph( N, mu, k, maxk, minc, maxc, weight_bounds=weight_scale * np.array([lower_weight_bound, upper_weight_bound]), deg_exp=deg_exp, temp_dir_ID=temp_dir_ID, full_path=full_path)
def generator_reservoir(self): """ Use another function to create the reservoir and return it """ self.nx_reservoir = graphgen.uniform_weighted_directed_lfr_graph( N=self.N, mu=self.mu, k=self.k, maxk=self.maxk, minc=self.minc, maxc=self.maxc, deg_exp=self.deg_exp, temp_dir_ID=self.temp_dir_ID, full_path=self.full_path, weight_bounds=self.reservoir_weight_scale * np.array([self.lower_reservoir_bound, self.upper_reservoir_bound])) return np.asarray(nx.to_numpy_matrix(self.nx_reservoir))
import numpy as np import networkx as nx import graphgen if __name__ == '__main__': """ """ graph = graphgen.uniform_weighted_directed_lfr_graph(N=40, mu=0.5, k=5, maxk=5, minc=10, maxc=10, deg_exp=1, temp_dir_ID=0, full_path=None, weight_bounds=1 * np.array([1, 1])) nx.write_gexf(graph, "high_mu_graph.gexf")
plt.xlabel("time") plt.ylabel("activity") plt.legend(loc=2) plt.xlim(1, len(activity) + 1) plt.tight_layout() plt.savefig(prefix + "_com_activity_ts.png", dpi=300) plt.clf() plt.close() nx_reservoir = graphgen.uniform_weighted_directed_lfr_graph( N=500, mu=0.01, k=6, maxk=6, minc=10, maxc=10, deg_exp=1.0, temp_dir_ID=str(np.random.randint(0, 1000)) + 'temptest', full_path= "/home/nathaniel/workspace/DiscreteESN/", #/N/u/njrodrig/BigRed2/topology_of_function/ weight_bounds=(-0.2, 1.0)) reservoir = np.asarray(nx.to_numpy_matrix(nx_reservoir)) esn = echostatenetwork.DESN(reservoir, neuron_type='sigmoid', neuron_pars={ 'c': 1, 'e': 10 }, init_state=(0.0, 0.6)) esn.run_reservoir(100, record=True) state_history = np.array(esn.network_history)