コード例 #1
0
def worker(experimental_parameters):

    random.seed()
    np.random.seed()

    results = []
    for parameter_set in experimental_parameters:
        reservoir = graphgen.uniform_weighted_directed_lfr_graph_asarray(
            N=parameter_set['N'],
            mu=parameter_set['mu'],
            k=parameter_set['k'],
            maxk=parameter_set['maxk'],
            minc=parameter_set['minc'],
            maxc=parameter_set['maxc'],
            deg_exp=parameter_set['deg_exp'],
            temp_dir_ID=parameter_set['temp_dir_ID'],
            full_path=parameter_set['full_path'],
            weight_bounds=parameter_set['reservoir_weight_scale'] *
            np.array(parameter_set['reservoir_weight_bounds']))
        esn = echostatenetwork.DESN(reservoir,
                                    neuron_type=parameter_set['neuron_type'],
                                    neuron_pars=parameter_set['neuron_pars'],
                                    init_state=parameter_set['ic'])

        results.append(
            (parameter_set[parameter_set['q1']],
             parameter_set[parameter_set['q2']],
             fixed_point_estimator.fixed_point_estimate(
                 esn, parameter_set['num_trials'], parameter_set['tmax'],
                 parameter_set['distance_thresh'], parameter_set['epsilon'],
                 parameter_set['convergence_delay'])))

    return results
コード例 #2
0
    def generate_esn(self):
        """
        """

        self.reservoir = self.generator_reservoir()

        self.input_weights = self.generate_input_weights()
        return echostatenetwork.DESN(self.reservoir, self.input_weights, 
            neuron_type=self.neuron_type, output_type=self.output_neuron_type, 
            neuron_pars=self.neuron_pars, output_neuron_pars=self.output_neuron_pars,
            init_state=self.init_state)
コード例 #3
0
    def __init__(self,
                 network,
                 input_weight_scale,
                 signal_ratio,
                 niter,
                 input_series,
                 neuron_type="tanh",
                 initialization_state="zeros",
                 neuron_pars=None,
                 input_weight_bounds=(-1.0, 1.0),
                 community_key=None,
                 seed=1,
                 target_community=None):
        """
        input_series needs to be a Lx1x1 vector or a list of Kx1 vectors. L is the length of the input. Simulation time exceeding L will assume inputs of 0
        """

        self.network = network
        self.signal_ratio = signal_ratio
        self.input_weight_scale = input_weight_scale
        self.state_history = []
        self.initialization_state = initialization_state
        self.niter = niter
        self.default_input = np.zeros((1, 1))
        self.neuron_type = neuron_type
        self.neuron_pars = neuron_pars
        self.input_series = input_series
        self.input_weight_bounds = input_weight_bounds
        self.community_key = community_key
        self.target_community = target_community

        # Generate input weights
        self.input_weights = self.CreateInputWeights(
            target_community=self.target_community,
            community_key=self.community_key)
        self.reservoir = nx.adjacency_matrix(
            self.network
        ).A  # toarray() may need to be added for different versions of networkx
        self.esn_model = echostatenetwork.DESN(
            self.reservoir,
            self.input_weights,
            self.neuron_type,
            init_state=self.initialization_state,
            neuron_pars=self.neuron_pars)
コード例 #4
0
    def generate_esn(self):
        """
        """

        self.reservoir = self.generator_reservoir()

        # Adjust spectral radius if not None
        if self.target_spectral_radius != None:
            spectral_radius = np.sort(
                np.absolute(np.linalg.eigvals(self.reservoir)))[-1]
            self.reservoir = self.reservoir / spectral_radius * self.target_spectral_radius

        self.input_weights = self.generate_input_weights()
        return echostatenetwork.DESN(
            self.reservoir,
            self.input_weights,
            neuron_type=self.neuron_type,
            output_type=self.output_neuron_type,
            neuron_pars=self.neuron_pars,
            output_neuron_pars=self.output_neuron_pars,
            init_state="zeros")
        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)
    state_history = state_history.reshape(
        (state_history.shape[0], state_history.shape[1]))
    plot_community_activity_timeseries("test", nx_reservoir, state_history)