odynn.neuron module¶
-
class
odynn.neuron.BioNeuronTf(init_p=None, dt=0.1, fixed=(), constraints=None, groups=None, n_rand=None)[source]¶ Bases:
odynn.models.celeg.CElegansNeuron,odynn.neuron.NeuronTfClass representing a neuron, implemented using Tensorflow. This class allows simulation and optimization, alone and in a Circuit. It can contain several neurons at the same time. Which in turn can be optimized in parallel, or be used to represent the entire neurons in a Circuit.
Attributes: groupslist indicating the group of each neuron
hidden_init_stateFor behavioral models eg LSTM
init_paramsinitial model parameters
init_statendarray, Initial state vector
numint, Number of neurons being modeled in this object
- parameter_names
trainableTrue if the object can be optimized
variablesCurrent variables of the models
Methods
apply_constraints(session)Apply the constraints to the object variables build_graph([batch])Build a tensorflow graph for running the neuron(s) on a series of input :param batch: dimension of the batch :type batch: int calculate(i)Iterate over i (current) and return the state variables obtained after each step get_random()Returns a dictionnary of random parameters init(batch)Method to implement whe initialization is needed, will be called before reset parallelize(n)Add a dimension of size n in the initial parameters and initial state plot_output(ts, i_inj, states[, y_states, …])Plot voltage and ion concentrations, potentially compared to a target model plot_results(ts, i_inj_values, results[, …])plot all dynamics plot_vars(var_dic[, suffix, show, save, func])plot variation/comparison/boxplots of all variables organized by categories plot_vars_gate(name, mdp, scale, tau, fig, …)plot the gates variables reset()rebuild tf variable graph settings()Returns(str): string describing the object step(X, i_inj)Integrate and update state variable (voltage and possibly others) after one time step apply_init boxplot_vars predump set_init_param study_vars -
__init__(init_p=None, dt=0.1, fixed=(), constraints=None, groups=None, n_rand=None)[source]¶ Initializer :param init_p: initial parameters of the neuron(s). If init_p is a list, then this object
will model n = len(init_p) neuronsParameters: - dt (float) – time step
- fixed (set) – parameters that are fixed and will stay constant in case of optimization. if fixed == ‘all’, all parameters will be constant
- constraints (dict of ndarray) – keys as parameters name, and values as [lower_bound, upper_bound]
-
apply_constraints(session)[source]¶ Apply the constraints to the object variables
Parameters: session – tensorflow session
-
build_graph(batch=None)[source]¶ Build a tensorflow graph for running the neuron(s) on a series of input :param batch: dimension of the batch :type batch: int
Returns: input placeholder and results of the run Return type: tf.placeholder, tf.Tensor
-
calculate(i)[source]¶ Iterate over i (current) and return the state variables obtained after each step
Parameters: i (ndarray) – input current Returns: state vectors concatenated [i.shape[0], len(self.init_state)(, i.shape[1]), self.num] Return type: ndarray
-
groups¶ list indicating the group of each neuron Neurons with the same group share the same parameters
-
init_params¶ initial model parameters
-
parallelize(n)[source]¶ Add a dimension of size n in the initial parameters and initial state
Parameters: n (int) – size of the new dimension
-
trainable¶ True if the object can be optimized
-
variables¶ Current variables of the models
-
class
odynn.neuron.NeuronLSTM(nb_layer=1, layer_size=50, extra_ca=0, dt=0.1, vars_init=None)[source]¶ Bases:
odynn.neuron.NeuronTfBehavior model of a neuron using an LSTM network
Attributes: groupslist indicating the group of each neuron
hidden_init_stateGive the initial state needed for the LSTM network
init_paramsInitial model parameters
init_statendarray, Initial state vector
numNumber of neurons contained in the object, always 1 here
trainableboolean stating if the neuron can be optimized
variablesdict, current Tf variables
Methods
apply_constraints(session)Apply necessary constraints to the optimized variables apply_init(sess)Initialize the variables if loaded object build_graph([batch])Build the tensorflow graph. calculate(i)Iterate over i (current) and return the state variables obtained after each step init(batch)Method to implement whe initialization is needed, will be called before reset plot_output(ts, i_inj, states[, y_states, …])Plot voltage and ion concentrations, potentially compared to a target model plot_vars(var_dic, suffix, show, save)A function to plot the variables of the optimized object settings()Returns(str): string describing the object step(X, hprev, i_inj)Update function predump reset study_vars -
build_graph(batch=1)[source]¶ Build the tensorflow graph. Take care of the loop and the initial state.
-
calculate(i)[source]¶ Iterate over i (current) and return the state variables obtained after each step
Parameters: i (ndarray) – input current Returns: state vectors concatenated [i.shape[0], len(self.init_state)(, i.shape[1]), self.num] Return type: ndarray
Give the initial state needed for the LSTM network
-
init(batch)[source]¶ Method to implement whe initialization is needed, will be called before reset
Parameters: batch (int) – number of batches
-
init_params¶ Initial model parameters
-
num¶ Number of neurons contained in the object, always 1 here
-
class
odynn.neuron.NeuronTf(dt=0.1)[source]¶ Bases:
odynn.models.model.Neuron,odynn.optim.OptimizedAbstract class whose implementation allow single optimization as well as in a Circuit
Attributes: groupslist indicating the group of each neuron
hidden_init_stateFor behavioral models eg LSTM
init_paramsdict, initial parameters
init_statendarray, Initial state vector
numint, Number of neurons being modeled in this object
trainableboolean stating if the neuron can be optimized
variablesdict, current Tf variables
Methods
apply_constraints(session)Apply necessary constraints to the optimized variables build_graph([batch])Build the tensorflow graph. calculate(i)Iterate over i (current) and return the state variables obtained after each step init(batch)Method to implement whe initialization is needed, will be called before reset plot_output(ts, i_inj, states[, y_states, …])Plot voltage and ion concentrations, potentially compared to a target model plot_vars(var_dic, suffix, show, save)A function to plot the variables of the optimized object settings()Give a string describing the settings Returns(str): description step(X, i)Integrate and update state variable (voltage and possibly others) after one time step apply_init predump study_vars -
default_init_state= array([-6.0e+01, 0.0e+00, 9.5e-01, 0.0e+00, 0.0e+00, 1.0e+00, 1.0e-07])¶
-
groups¶ list indicating the group of each neuron Neurons with the same group share the same parameters
For behavioral models eg LSTM
-
init(batch)[source]¶ Method to implement whe initialization is needed, will be called before reset
Parameters: batch (int) – number of batches
-
nb= 0¶
-
trainable¶ boolean stating if the neuron can be optimized
-
class
odynn.neuron.Neurons(neurons)[source]¶ Bases:
odynn.neuron.NeuronTfThis class allow to use neurons from different classes inheriting NeuronTf in a same Circuit
Attributes: groupslist indicating the group of each neuron
hidden_init_stateFor behavioral models eg LSTM
init_paramsdict, initial parameters
init_statendarray, Initial state vector
numint, Number of neurons being modeled in this object
trainableboolean stating if the neuron can be optimized
variablesdict, current Tf variables
Methods
apply_constraints(session)Apply the constraints to the object variables build_graph()Build the tensorflow graph. calculate(i)Iterate over i (current) and return the state variables obtained after each step init(batch)call init method for all contained neuron objects plot_output(ts, i_inj, states[, y_states, …])Plot voltage and ion concentrations, potentially compared to a target model plot_vars(var_dic, suffix, show, save)A function to plot the variables of the optimized object settings()Returns(str): string describing the object step(X, hidden, i)Share the state and the input current into its embedded neurons apply_init predump reset study_vars -
__init__(neurons)[source]¶ Parameters: neurons (list) – list of NeuronTf objects Raises: AttributeError– If all neurons don’t share the same dt
-
apply_constraints(session)[source]¶ Apply the constraints to the object variables
Parameters: session – tensorflow session
-
calculate(i)[source]¶ Iterate over i (current) and return the state variables obtained after each step
Parameters: i (ndarray) – input current Returns: state vectors concatenated [i.shape[0], len(self.init_state)(, i.shape[1]), self.num] Return type: ndarray
For behavioral models eg LSTM
-
class
odynn.neuron.PyBioNeuron(init_p=None, dt=0.1)[source]¶ Bases:
odynn.models.celeg.CElegansNeuronClass representing a neuron, implemented only in Python This class allows simulation but not optimization
Attributes: init_statendarray, Initial state vector
numint, Number of neurons being modeled in this object
- parameter_names
Methods
calculate(i_inj)Simulate the neuron with input current i_inj and return the state vectors get_random()Returns a dictionnary of random parameters parallelize(n)Add a dimension of size n in the initial parameters and initial state plot_output(ts, i_inj, states[, y_states, …])Plot voltage and ion concentrations, potentially compared to a target model plot_results(ts, i_inj_values, results[, …])plot all dynamics plot_vars(var_dic[, suffix, show, save, func])plot variation/comparison/boxplots of all variables organized by categories plot_vars_gate(name, mdp, scale, tau, fig, …)plot the gates variables step(X, i_inj)Integrate and update state variable (voltage and possibly others) after one time step boxplot_vars study_vars