bmtk.simulator.dpointnet package#
Subpackages#
- bmtk.simulator.dpointnet.cell_models package
- Submodules
- bmtk.simulator.dpointnet.cell_models.glif3_cell module
GLIF3CellGLIF3Cell.calculate_i_rec_with_custom_grad()GLIF3Cell.calculate_input_current_from_firing_probabilities()GLIF3Cell.calculate_input_current_from_spikes()GLIF3Cell.calculate_noise_current()GLIF3Cell.call()GLIF3Cell.output_sizeGLIF3Cell.refresh_recurrent_weight_shadow()GLIF3Cell.state_sizeGLIF3Cell.update_psc()GLIF3Cell.zero_state()
SignedConstraintcalculate_input_currents()calculate_synaptic_currents()gauss_pseudo()get_new_inds_table()make_pre_ind_table()njit()pseudo_derivative()spike_function()spike_gauss()straight_through_dampen()
- Module contents
- bmtk.simulator.dpointnet.input_modules package
- Submodules
- bmtk.simulator.dpointnet.input_modules.inputs_base module
- bmtk.simulator.dpointnet.input_modules.lgn_generator module
- bmtk.simulator.dpointnet.input_modules.noisy_current module
- bmtk.simulator.dpointnet.input_modules.poisson_spikes module
- bmtk.simulator.dpointnet.input_modules.rand_spikes_generator module
- bmtk.simulator.dpointnet.input_modules.spikes_files_generator module
- bmtk.simulator.dpointnet.input_modules.spikes_function_generator module
- Module contents
- bmtk.simulator.dpointnet.lgn_tf package
- bmtk.simulator.dpointnet.loss_functions package
- Submodules
- bmtk.simulator.dpointnet.loss_functions.loss_utils module
compute_spike_rate_distribution_loss()compute_spike_rate_target_loss()get_pop_names()get_population_neuron_ids()get_tuning_angles()huber_quantile_loss()isolate_core_neurons()neuropixels_cell_type_to_cell_type()pop_name_to_cell_type()process_neuropixels_data()resolve_core_mask()sample_firing_rates()spike_trimming()
- bmtk.simulator.dpointnet.loss_functions.orientation_selectivity_loss module
OrientationSelectivityLossOrientationSelectivityLoss.calculate_delta_angle()OrientationSelectivityLoss.crowd_osi_loss()OrientationSelectivityLoss.crowd_spikes_loss()OrientationSelectivityLoss.get_neuropixels_osi_dsi()OrientationSelectivityLoss.module()OrientationSelectivityLoss.update_normalizers()OrientationSelectivityLoss.uses_ema_normalizer
- bmtk.simulator.dpointnet.loss_functions.spike_rate_distribution_target module
- bmtk.simulator.dpointnet.loss_functions.synchronization_loss module
- bmtk.simulator.dpointnet.loss_functions.target_firing_rates module
- bmtk.simulator.dpointnet.loss_functions.voltage_regularization module
- bmtk.simulator.dpointnet.loss_functions.weight_regularization module
- Module contents
- bmtk.simulator.dpointnet.state_modules package
Submodules#
bmtk.simulator.dpointnet.callbacks module#
- class bmtk.simulator.dpointnet.callbacks.Callbacks(rnn, callbacks_dir='callbacks_outputs', starting_epoch=0, verbose='full', time_fmt='%d-%m-%Y %H:%M', epoch_store_weights='best', epoch_cache_weights=False, epoch_cach_dir='weights', sonata_output_dir='trained_weights', losses_table_csv='losses.csv', performance_table_csv='performance.csv')[source]#
Bases:
object- property n_epochs#
- property steps_per_epoch#
- property time#
- class bmtk.simulator.dpointnet.callbacks.GPUMem(name, tf_current, tf_peak, gpu_used, gpu_free, gpu_total)#
Bases:
tuple- gpu_free#
Alias for field number 4
- gpu_total#
Alias for field number 5
- gpu_used#
Alias for field number 3
- name#
Alias for field number 0
- tf_current#
Alias for field number 1
- tf_peak#
Alias for field number 2
- class bmtk.simulator.dpointnet.callbacks.Verbosity(*values)[source]#
Bases:
IntEnum- full = 4#
- on_epoch = 2#
- on_step = 3#
- on_train = 1#
- quiet = 0#
bmtk.simulator.dpointnet.config module#
- class bmtk.simulator.dpointnet.config.Config(*args, **kwargs)[source]#
Bases:
SimulationConfig
bmtk.simulator.dpointnet.data_iterator module#
bmtk.simulator.dpointnet.id_maps module#
- class bmtk.simulator.dpointnet.id_maps.TFIDMap[source]#
Bases:
objectMain class used to map SONATA node_ids to tensorflow neuron ids (tf-ids)
This is a singleton class, meaning that for the lifespan of the Python interpreter run the mapping between node-ids and tf-ids will not change. TODO: Consider using Multion pattern that can be tied to each RNN instance.
Things this class must take care of. 1. tf-ids must start with 0 and be contigious. SONATA node_ids must be positive non-overlapping intergers,
but may have gaps and can be out-of-order.
Recurrent nodes (eg. glif cells) must not have overlapping tf-ids. However in SONATA it is possible for a recurrent network to be made up of multiple populations with overlapping node-ids.
Each input network (eg. virtual cell) must have tf-ids [0, n_input_cells]. As above this is not required for SONATA.
bmtk.simulator.dpointnet.io_tools module#
bmtk.simulator.dpointnet.network_adaptor module#
- class bmtk.simulator.dpointnet.network_adaptor.CachedNetwork(name, file_path, network_type, file_format=None, **options)[source]#
Bases:
NetworkAdaptor- property n_nodes#
- class bmtk.simulator.dpointnet.network_adaptor.NetworkAdaptor(name, network_type, **options)[source]#
Bases:
object- property connection_table#
- static from_params(cache_file=None, network_type=None, network_name=None, file_format=None)[source]#
- property input_options#
- property input_type#
- property n_nodes#
- property n_spiking_nodes#
- property population_name#
- property source_node_ids#
- property source_tf_ids#
- property target_node_ids#
- property target_tf_ids#
- class bmtk.simulator.dpointnet.network_adaptor.SONATANetwork(sonata_node_pop, network_type, cache_file=False, filter=None, **opt_args)[source]#
Bases:
NetworkAdaptor- property md5hexsdigest#
- property n_nodes#
bmtk.simulator.dpointnet.optimizers module#
- class bmtk.simulator.dpointnet.optimizers.ExponentiatedAdam(*args: Any, **kwargs: Any)[source]#
Bases:
OptimizerAdam-like optimizer with exponentiated gradient updates.
This rewrites the final update from
w <- w - alpha * m / (sqrt(v) + epsilon)
to
w <- w * exp(- alpha * m / (sqrt(v) + epsilon) * sign(w)),
preserving the rest of the Adam algorithm (moments m, v, AMSGrad, etc.). By default, sign(0) = +1 so zero-valued parameters can still move off zero.
Sparse updates are applied consistently via scatter_mul() on the affected slices only.
- Reference:
“Brain-like learning with exponentiated gradients” (and related papers).
The original Adam reference: [Kingma et al., 2014](http://arxiv.org/abs/1412.6980).
- class bmtk.simulator.dpointnet.optimizers.LinearWarmupCosineDecay(*args: Any, **kwargs: Any)[source]#
Bases:
LearningRateScheduleLinear, warmpu followed by cosine decay.
bmtk.simulator.dpointnet.results module#
bmtk.simulator.dpointnet.rnn_model module#
- class bmtk.simulator.dpointnet.rnn_model.Inference(rnn, name='inference', batch_size=None, seq_len=None)[source]#
Bases:
object- property data_itr#
- property effective_batch_size#
- property effective_seq_len#
- class bmtk.simulator.dpointnet.rnn_model.RNN(seq_len=None, batch_size=None, dtype='float32', dt=1.0, default_seed=None, cell_cls=None, cell_params=None, **kwargs)[source]#
Bases:
objectThe primary model and simulation class for dpointnet.
This class is used to store and coordinate all the neccessary information to build, train, and run predctions on the GLIF Recurrent Neural Network model. Includes storing information about the original (sonata) network, the RNN model, and any spiking and state inputs used during training and prediction. It can also be used to extract weights and results from any previous training/predictions.
- property adjusted_batch_size#
- property adjusted_seq_len#
- build(rebuild=False, seq_len=None, dtype=tensorflow.float32, use_dummy_state_input=False, use_state_input=True, n_output=2, return_state=True, batch_size=None, **kwargs)[source]#
- property cell#
- property inference#
- property input_modules#
- property input_populations#
- property inputs_populations#
- property node_populations#
- property ordered_inputs_populations#
- property recurrent_network#
- property rsnn_layer#
- run()[source]#
A generic function to run a full execution of the RNN including building, training, running inference, and saving results (only training/inference/output parameters have been added to the RNN in the config or API).
This is primarily designed for use with the SONATA config, so that user may run:
$ python run_dpointnet.py config.json
and not have to change any of the python code - only the json file. For more grainular control you can call the build(…), train(…), and run_inference(…) function directly through the Python API.
- property state_only_model#
- property training_engine#
bmtk.simulator.dpointnet.spikes_generator module#
- bmtk.simulator.dpointnet.spikes_generator.add_background_noise(spikes_table, noise_rate, dt)[source]#
bmtk.simulator.dpointnet.tf_utils module#
- bmtk.simulator.dpointnet.tf_utils.enable_tensorflow_optimizations(enabled=True)[source]#
Enable Grappler graph optimizations (matches the reference V1_GLIF_model).
The critical one for this model is
loop_optimization: it performs loop-invariant code motion, hoisting the constant connectivity-variable reads (recurrent/LGN indices, weights, syn_ids) OUT of the RNN tf.while_loop body. Without it, TF re-reads those large tables every timestep and stacks them for the backward pass, which makes backward memory scale with seq_len and OOMs full-network training.min_graph_nodes=0lets Grappler optimize the many small subgraphs in this model.
bmtk.simulator.dpointnet.training module#
- class bmtk.simulator.dpointnet.training.InputsSignatureFactory(pnames, ordered_input_pops, ordered_input_mods)[source]#
Bases:
object
- class bmtk.simulator.dpointnet.training.TrainingEngine(rnn, n_epochs, steps_per_epoch, training_approach=None, **kwargs)[source]#
Bases:
object- property adjusted_batch_size#
- property adjusted_seq_len#
- property batch_indices#
- property callbacks#
- property init_state#
- property inputs_signature_factory#
- property n_parameters#
- property optimizer#
- property parameters#
- property step_train_function#
- property training_approach#