odynn.optim module

class odynn.optim.Optimized(dt)[source]

Bases: abc.ABC

Abstract class for object to be optimized. It could represent on or a set of neurons, or a circuit.

Attributes:
init_params

dict, initial parameters

num

int, number of models

variables

dict, current Tf variables

Methods

apply_constraints(session) Apply necessary constraints to the optimized variables
build_graph([batch]) Build the tensorflow graph.
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
apply_init  
predump  
study_vars  
apply_constraints(session)[source]

Apply necessary constraints to the optimized variables

Parameters:session (tf.Session) –
apply_init(session)[source]
build_graph(batch=1)[source]

Build the tensorflow graph. Take care of the loop and the initial state.

init_params

dict, initial parameters

ions = {}
num

int, number of models

static plot_vars(var_dic, suffix, show, save)[source]

A function to plot the variables of the optimized object

Parameters:
  • var_dic
  • suffix
  • show
  • save
predump(sess)[source]
settings()[source]

Give a string describing the settings Returns(str): description

study_vars(p, *args, **kwargs)[source]
variables

dict, current Tf variables

class odynn.optim.Optimizer(optimized, frequency=30)[source]

Bases: abc.ABC

Methods

settings(w, train) Give the settings of the optimization
optimize  
plot_out  
__init__(optimized, frequency=30)[source]
Parameters:
  • optimized (Optimized) –
  • epochs
  • frequency
optimize(dir, train_=None, test_=None, w=None, epochs=700, l_rate=(0.1, 9, 0.92), suffix='', step='', reload=False, reload_dir=None, yshape=None, evol_var=True, plot=True)[source]
plot_out(*args, **kwargs)[source]
settings(w, train)[source]

Give the settings of the optimization

Parameters:w (tuple) – weights for the loss of voltage and ions concentrations
Returns:settings
Return type:str
odynn.optim.get_best_result(dir, i=-1, loss=False)[source]
Parameters:dir (str) – path to the directory i: (Default value = -1)

Returns:

odynn.optim.get_data(dir)[source]
odynn.optim.get_model(dir)[source]
odynn.optim.get_vars(dir, i=-1, loss=False)[source]

get dic of vars from dumped file

Parameters:dir (str) – path to the directory i: (Default value = -1)

Returns:

odynn.optim.get_vars_all(dir, i=-1, losses=False)[source]

get dic of vars from dumped file

Parameters:dir (str) – path to the directory i: (Default value = -1)

Returns:

odynn.optim.plot_loss_rate(losses, rates, losses_test=None, parallel=1, suffix='', show=False, save=True)[source]

plot loss (log10) and learning rate

Parameters:
  • losses
  • rates
  • losses_test – (Default value = None)
  • parallel – (Default value = 1)
  • suffix – (Default value = “”)
  • show (bool) – If True, show the figure (Default value = False)
  • save – (Default value = True)

Returns: