예제 #1
0
파일: network.py 프로젝트: kushs123/pynam
    def __init__(self, data={}, burst_size=1):
        """
        Constructor of the OutputParameters class. Either copies the parameters
        from the given "data" dictionary or uses the given arguments.

        :param data: dictionary the arguments are preferably copied from.
        :param burst_size: number of expected output spikes in a neuron.
        """
        utils.init_key(self, data, "burst_size", burst_size, _type=int)
예제 #2
0
파일: network.py 프로젝트: apdavison/pynam
    def __init__(self, data={}, burst_size=1):
        """
        Constructor of the OutputParameters class. Either copies the parameters
        from the given "data" dictionary or uses the given arguments.

        :param data: dictionary the arguments are preferably copied from.
        :param burst_size: number of expected output spikes in a neuron.
        """
        utils.init_key(self, data, "burst_size", burst_size, _type=int)
예제 #3
0
    def __init__(self, data={}, data_params={}, topology_params={},
            input_params={}, output_params={}, experiments=[]):
        utils.init_key(self, data, "data", data_params)
        utils.init_key(self, data, "topology", topology_params)
        utils.init_key(self, data, "input", input_params)
        utils.init_key(self, data, "output", output_params)
        utils.init_key(self, data, "experiments", experiments)

        self["data"] = DataParameters(self["data"])
        self["topology"] = TopologyParameters(self["topology"])
        self["input"] = InputParameters(self["input"])
        self["output"] = OutputParameters(self["output"])

        if not isinstance(self["experiments"], list):
            self["experiments"] = [self["experiments"]]
        for i in xrange(len(self["experiments"])):
            self["experiments"][i] = ExperimentDescriptor(
                    self["experiments"][i])
예제 #4
0
 def __init__(self, data={}, name="", repeat=1, sweeps={}):
     """
     Creates an experiment descriptor, which consists of a repeat count and
     a number of sweep descriptors for the dimensions that should be varied.
     """
     utils.init_key(self, data, "name", name)
     utils.init_key(self, data, "repeat", repeat)
     utils.init_key(self, data, "sweeps", sweeps)
예제 #5
0
파일: network.py 프로젝트: kushs123/pynam
    def __init__(self, data={}, burst_size=1, time_window=100.0, isi=1.0,
                 sigma_t=0.0, sigma_t_offs=0.0, p0=0.0, p1=0.0):
        """
        Constructor of the InputParameters class. If a dictionary or another
        InputParameters class is passed as first parameter, elements from this
        instance are copied with a precedence over the specified parameters.

        :param data: dictionary from which parameters are copied preferably.
        :param burst_size: number of spikes representing a "one".
        :param time_window: time between the presentation of two input samples.
        :param isi: inter spike interval between spike of a burst.
        :param sigma_t: spike jitter
        :param sigma_t_offs: spike offset jitter
        :param p0: probability with which individual spikes are omitted.
        :param p1: probability with which spikes from a "one" are randomly
        introduced for a sample containing zeros.
        """
        utils.init_key(self, data, "burst_size", burst_size, _type=int)
        utils.init_key(self, data, "time_window", time_window)
        utils.init_key(self, data, "isi", isi)
        utils.init_key(self, data, "sigma_t", sigma_t)
        utils.init_key(self, data, "sigma_t_offs", sigma_t_offs)
        utils.init_key(self, data, "p0", p0)
        utils.init_key(self, data, "p1", p1)
예제 #6
0
파일: network.py 프로젝트: kushs123/pynam
    def __init__(self, data={}, input_times=[], input_indices=[],
                 output_times=[], output_indices=[], input_params={},
                 data_params={},
                 topology_params={}, meta_data={}, mat_in=[], mat_out=[]):
        utils.init_key(self, data, "input_times", input_times)
        utils.init_key(self, data, "input_indices", input_indices)
        utils.init_key(self, data, "output_times", output_times)
        utils.init_key(self, data, "output_indices", output_indices)
        utils.init_key(self, data, "input_params", input_params)
        utils.init_key(self, data, "data_params", data_params)
        utils.init_key(self, data, "topology_params", topology_params)
        utils.init_key(self, data, "meta_data", meta_data)
        utils.init_key(self, data, "mat_in", mat_in)
        utils.init_key(self, data, "mat_out", mat_out)

        self["input_params"] = InputParameters(self["input_params"])
        self["data_params"] = DataParameters(self["data_params"])
        self["topology_params"] = TopologyParameters(self["topology_params"])
예제 #7
0
파일: network.py 프로젝트: kushs123/pynam
    def __init__(self, data={}, name="", populations=[], connections=[],
                 input_times=[], input_indices=[], input_split=[],
                 spatial_split=[],
                 input_params=[], data_params=[], topology_params=[],
                 meta_data=[],
                 mat_in=[], mat_out=[]):
        utils.init_key(self, data, "name", name)
        utils.init_key(self, data, "populations", populations)
        utils.init_key(self, data, "connections", connections)
        utils.init_key(self, data, "input_times", input_times)
        utils.init_key(self, data, "input_indices", input_indices)
        utils.init_key(self, data, "input_split", input_split)
        utils.init_key(self, data, "spatial_split", spatial_split)
        utils.init_key(self, data, "input_params", input_params)
        utils.init_key(self, data, "meta_data", meta_data)
        utils.init_key(self, data, "data_params", data_params)
        utils.init_key(self, data, "topology_params", topology_params)
        utils.init_key(self, data, "mat_in", mat_in)
        utils.init_key(self, data, "mat_out", mat_out)

        # Fix things up in case a NetworkInstance was passed to the constructor
        if (len(self["spatial_split"]) == 0 and len(self["populations"]) > 0):
            self["input_split"] = [self["input_split"]]
            self["input_params"] = [self["input_params"]]
            self["data_params"] = [self["data_params"]]
            self["topology_params"] = [self["topology_params"]]
            self["meta_data"] = [self["meta_data"]]
            self["mat_in"] = [self["mat_in"]]
            self["mat_out"] = [self["mat_out"]]
            self["spatial_split"].append({
                "population": len(self["populations"]),
                "input": len(self["input_times"])
            });
예제 #8
0
파일: network.py 프로젝트: kushs123/pynam
    def __init__(self, data={}, populations=[], connections=[],
                 input_times=[], input_indices=[], input_split=[],
                 input_params={},
                 data_params={}, topology_params={}, meta_data={}, mat_in=[],
                 mat_out=[]):
        utils.init_key(self, data, "populations", populations)
        utils.init_key(self, data, "connections", connections)
        utils.init_key(self, data, "input_times", input_times)
        utils.init_key(self, data, "input_indices", input_indices)
        utils.init_key(self, data, "input_split", input_split)
        utils.init_key(self, data, "input_params", input_params)
        utils.init_key(self, data, "data_params", data_params)
        utils.init_key(self, data, "topology_params", topology_params)
        utils.init_key(self, data, "meta_data", meta_data)
        utils.init_key(self, data, "mat_in", mat_in)
        utils.init_key(self, data, "mat_out", mat_out)

        if not isinstance(self["input_params"], list):
            self["input_params"] = [self["input_params"]]
        for i in xrange(len(self["input_params"])):
            self["input_params"][i] = InputParameters(self["input_params"][i])
        self["data_params"] = DataParameters(self["data_params"])
        self["topology_params"] = TopologyParameters(self["topology_params"])
예제 #9
0
파일: network.py 프로젝트: kushs123/pynam
    def __init__(self, data={}, n_bits_in=16, n_bits_out=16, n_ones_in=3,
                 n_ones_out=3, n_samples=-1, algorithm="balanced"):
        """
        Fills the network structure with the given parameters.

        :param n_bits_in: number of input bits.
        :param n_bits_out: number of output bits.
        :param n_ones_in: number of ones in the input per sample.
        :param n_ones_out: number of ones in the output per sample.
        :param n_samples: number of samples. If negative, the number of samples
        with the maximum information are chosen.
        """

        # If "n_bits" is specified, set both n_bits_in and n_bits_out
        if ("n_bits" in data) and (data["n_bits"] > 0):
            self["n_bits_in"] = int(data["n_bits"])
            self["n_bits_out"] = int(data["n_bits"])
            self["n_bits"] = int(data["n_bits"])
        else:
            utils.init_key(self, data, "n_bits_in", n_bits_in, _type=int)
            utils.init_key(self, data, "n_bits_out", n_bits_out, _type=int)
            utils.init_key(self, data, "n_bits",
                           self["n_bits_in"] if self["n_bits_in"] == self[
                               "n_bits_out"]
                           else -1, _type=int)
        utils.init_key(self, data, "n_ones_in", n_ones_in, _type=int)
        utils.init_key(self, data, "n_ones_out", n_ones_out, _type=int)
        utils.init_key(self, data, "n_samples", n_samples, _type=int)
        utils.init_key(self, data, "algorithm", algorithm, _type=str)

        if not self["algorithm"] in ["random", "balanced", "unique"]:
            raise Exception("Invalid data generation algorithm \""
                            + self["algorithm"]
                            + "\", must be one of {\"random\", \"balanced\", \"unique\"}!")

        # If n_ones_in and n_ones_out is not given, automatically calculate
        # n_ones_in, n_ones_out and n_samples
        if (self["n_ones_in"] <= 0) and (self["n_ones_out"] <= 0):
            params = entropy.optimal_parameters(n_samples=self["n_samples"],
                                                n_bits_in=self["n_bits_in"],
                                                n_bits_out=self["n_bits_out"])
            self["n_samples"] = params["n_samples"]
            self["n_ones_in"] = params["n_ones_in"]
            self["n_ones_out"] = params["n_ones_out"]

        # Automatically choose the optimal number of samples
        if self["n_samples"] <= 0:
            self["n_samples"] = entropy.optimal_sample_count(
                n_bits_out=self["n_bits_out"],
                n_bits_in=self["n_bits_in"],
                n_ones_out=self["n_ones_out"],
                n_ones_in=self["n_ones_in"])
예제 #10
0
파일: network.py 프로젝트: apdavison/pynam
    def __init__(
        self,
        data={},
        input_times=[],
        input_indices=[],
        output_times=[],
        output_indices=[],
        input_params={},
        data_params={},
        topology_params={},
        meta_data={},
        mat_in=[],
        mat_out=[],
    ):
        utils.init_key(self, data, "input_times", input_times)
        utils.init_key(self, data, "input_indices", input_indices)
        utils.init_key(self, data, "output_times", output_times)
        utils.init_key(self, data, "output_indices", output_indices)
        utils.init_key(self, data, "input_params", input_params)
        utils.init_key(self, data, "data_params", data_params)
        utils.init_key(self, data, "topology_params", topology_params)
        utils.init_key(self, data, "meta_data", meta_data)
        utils.init_key(self, data, "mat_in", mat_in)
        utils.init_key(self, data, "mat_out", mat_out)

        self["input_params"] = InputParameters(self["input_params"])
        self["data_params"] = DataParameters(self["data_params"])
        self["topology_params"] = TopologyParameters(self["topology_params"])
예제 #11
0
파일: network.py 프로젝트: apdavison/pynam
    def __init__(
        self,
        data={},
        name="",
        populations=[],
        connections=[],
        input_times=[],
        input_indices=[],
        input_split=[],
        spatial_split=[],
        input_params=[],
        data_params=[],
        topology_params=[],
        meta_data=[],
        mat_in=[],
        mat_out=[],
    ):
        utils.init_key(self, data, "name", name)
        utils.init_key(self, data, "populations", populations)
        utils.init_key(self, data, "connections", connections)
        utils.init_key(self, data, "input_times", input_times)
        utils.init_key(self, data, "input_indices", input_indices)
        utils.init_key(self, data, "input_split", input_split)
        utils.init_key(self, data, "spatial_split", spatial_split)
        utils.init_key(self, data, "input_params", input_params)
        utils.init_key(self, data, "meta_data", meta_data)
        utils.init_key(self, data, "data_params", data_params)
        utils.init_key(self, data, "topology_params", topology_params)
        utils.init_key(self, data, "mat_in", mat_in)
        utils.init_key(self, data, "mat_out", mat_out)

        # Fix things up in case a NetworkInstance was passed to the constructor
        if len(self["spatial_split"]) == 0 and len(self["populations"]) > 0:
            self["input_split"] = [self["input_split"]]
            self["input_params"] = [self["input_params"]]
            self["data_params"] = [self["data_params"]]
            self["topology_params"] = [self["topology_params"]]
            self["meta_data"] = [self["meta_data"]]
            self["mat_in"] = [self["mat_in"]]
            self["mat_out"] = [self["mat_out"]]
            self["spatial_split"].append({"population": len(self["populations"]), "input": len(self["input_times"])})
예제 #12
0
파일: network.py 프로젝트: apdavison/pynam
    def __init__(
        self,
        data={},
        populations=[],
        connections=[],
        input_times=[],
        input_indices=[],
        input_split=[],
        input_params={},
        data_params={},
        topology_params={},
        meta_data={},
        mat_in=[],
        mat_out=[],
    ):
        utils.init_key(self, data, "populations", populations)
        utils.init_key(self, data, "connections", connections)
        utils.init_key(self, data, "input_times", input_times)
        utils.init_key(self, data, "input_indices", input_indices)
        utils.init_key(self, data, "input_split", input_split)
        utils.init_key(self, data, "input_params", input_params)
        utils.init_key(self, data, "data_params", data_params)
        utils.init_key(self, data, "topology_params", topology_params)
        utils.init_key(self, data, "meta_data", meta_data)
        utils.init_key(self, data, "mat_in", mat_in)
        utils.init_key(self, data, "mat_out", mat_out)

        if not isinstance(self["input_params"], list):
            self["input_params"] = [self["input_params"]]
        for i in xrange(len(self["input_params"])):
            self["input_params"][i] = InputParameters(self["input_params"][i])
        self["data_params"] = DataParameters(self["data_params"])
        self["topology_params"] = TopologyParameters(self["topology_params"])
예제 #13
0
파일: network.py 프로젝트: apdavison/pynam
    def __init__(
        self, data={}, n_bits_in=16, n_bits_out=16, n_ones_in=3, n_ones_out=3, n_samples=-1, algorithm="balanced"
    ):
        """
        Fills the network structure with the given parameters.

        :param n_bits_in: number of input bits.
        :param n_bits_out: number of output bits.
        :param n_ones_in: number of ones in the input per sample.
        :param n_ones_out: number of ones in the output per sample.
        :param n_samples: number of samples. If negative, the number of samples
        with the maximum information are chosen.
        """

        # If "n_bits" is specified, set both n_bits_in and n_bits_out
        if ("n_bits" in data) and (data["n_bits"] > 0):
            self["n_bits_in"] = int(data["n_bits"])
            self["n_bits_out"] = int(data["n_bits"])
            self["n_bits"] = int(data["n_bits"])
        else:
            utils.init_key(self, data, "n_bits_in", n_bits_in, _type=int)
            utils.init_key(self, data, "n_bits_out", n_bits_out, _type=int)
            utils.init_key(
                self, data, "n_bits", self["n_bits_in"] if self["n_bits_in"] == self["n_bits_out"] else -1, _type=int
            )
        utils.init_key(self, data, "n_ones_in", n_ones_in, _type=int)
        utils.init_key(self, data, "n_ones_out", n_ones_out, _type=int)
        utils.init_key(self, data, "n_samples", n_samples, _type=int)
        utils.init_key(self, data, "algorithm", algorithm, _type=str)

        if not self["algorithm"] in ["random", "balanced", "unique"]:
            raise Exception(
                'Invalid data generation algorithm "'
                + self["algorithm"]
                + '", must be one of {"random", "balanced", "unique"}!'
            )

        # If n_ones_in and n_ones_out is not given, automatically calculate
        # n_ones_in, n_ones_out and n_samples
        if (self["n_ones_in"] <= 0) and (self["n_ones_out"] <= 0):
            params = entropy.optimal_parameters(
                n_samples=self["n_samples"], n_bits_in=self["n_bits_in"], n_bits_out=self["n_bits_out"]
            )
            self["n_samples"] = params["n_samples"]
            self["n_ones_in"] = params["n_ones_in"]
            self["n_ones_out"] = params["n_ones_out"]

        # Automatically choose the optimal number of samples
        if self["n_samples"] <= 0:
            self["n_samples"] = entropy.optimal_sample_count(
                n_bits_out=self["n_bits_out"],
                n_bits_in=self["n_bits_in"],
                n_ones_out=self["n_ones_out"],
                n_ones_in=self["n_ones_in"],
            )
예제 #14
0
파일: network.py 프로젝트: apdavison/pynam
    def __init__(
        self, data={}, params={}, param_noise={}, multiplicity=1, neuron_type=pynl.TYPE_IF_COND_EXP, w=0.03, sigma_w=0.0
    ):
        """
        Constructor of the TopologyParameters class.

        :param data: is a dictionary from which the arguments are copied
        preferably.
        :param params: dictionary containing the neuron parameters.
        :param param_noise: dictionary potentially containing a standard
        deviation for each parameter.
        :param multiplicity: number of neurons and signals each component is
        represented with.
        :param neuron_type: PyNNLess neuron type name.
        :param w: synapse weight
        :param sigma_w: synapse weight standard deviation.
        """
        utils.init_key(self, data, "params", params)
        utils.init_key(self, data, "param_noise", param_noise)
        utils.init_key(self, data, "multiplicity", multiplicity)
        utils.init_key(self, data, "neuron_type", neuron_type)
        utils.init_key(self, data, "w", w)
        utils.init_key(self, data, "sigma_w", sigma_w)

        self["params"] = self._restore_alternatives(
            pynl.PyNNLess.merge_default_parameters(self["params"], self["neuron_type"]), self["params"]
        )
예제 #15
0
 def __init__(self, data={}, vmin=0, vmax=1, count=10):
     utils.init_key(self, data, "min", vmin)
     utils.init_key(self, data, "max", vmax)
     utils.init_key(self, data, "count", count)
예제 #16
0
파일: network.py 프로젝트: kushs123/pynam
    def __init__(self, data={}, params={}, param_noise={}, multiplicity=1,
                 neuron_type=pynl.TYPE_IF_COND_EXP, w=0.03, sigma_w=0.0):
        """
        Constructor of the TopologyParameters class.

        :param data: is a dictionary from which the arguments are copied
        preferably.
        :param params: dictionary containing the neuron parameters.
        :param param_noise: dictionary potentially containing a standard
        deviation for each parameter.
        :param multiplicity: number of neurons and signals each component is
        represented with.
        :param neuron_type: PyNNLess neuron type name.
        :param w: synapse weight
        :param sigma_w: synapse weight standard deviation.
        """
        utils.init_key(self, data, "params", params)
        utils.init_key(self, data, "param_noise", param_noise)
        utils.init_key(self, data, "multiplicity", multiplicity)
        utils.init_key(self, data, "neuron_type", neuron_type)
        utils.init_key(self, data, "w", w)
        utils.init_key(self, data, "sigma_w", sigma_w)

        self["params"] = self._restore_alternatives(
            pynl.PyNNLess.merge_default_parameters(self["params"],
                                                   self["neuron_type"]),
            self["params"])
예제 #17
0
파일: network.py 프로젝트: apdavison/pynam
    def __init__(
        self, data={}, burst_size=1, time_window=100.0, isi=1.0, sigma_t=0.0, sigma_t_offs=0.0, p0=0.0, p1=0.0
    ):
        """
        Constructor of the InputParameters class. If a dictionary or another
        InputParameters class is passed as first parameter, elements from this
        instance are copied with a precedence over the specified parameters.

        :param data: dictionary from which parameters are copied preferably.
        :param burst_size: number of spikes representing a "one".
        :param time_window: time between the presentation of two input samples.
        :param isi: inter spike interval between spike of a burst.
        :param sigma_t: spike jitter
        :param sigma_t_offs: spike offset jitter
        :param p0: probability with which individual spikes are omitted.
        :param p1: probability with which spikes from a "one" are randomly
        introduced for a sample containing zeros.
        """
        utils.init_key(self, data, "burst_size", burst_size, _type=int)
        utils.init_key(self, data, "time_window", time_window)
        utils.init_key(self, data, "isi", isi)
        utils.init_key(self, data, "sigma_t", sigma_t)
        utils.init_key(self, data, "sigma_t_offs", sigma_t_offs)
        utils.init_key(self, data, "p0", p0)
        utils.init_key(self, data, "p1", p1)