Added LIF neuron.#189
Open
DavidIkov wants to merge 14 commits intoKasperskyLab:masterfrom
Open
Conversation
artiomn
requested changes
May 8, 2026
| * @kaspersky_support Postnikov D. | ||
| * @date 08.12.2025 | ||
| * @license Apache 2.0 | ||
| * @copyright © 2025 AO Kaspersky Lab |
Comment on lines
+50
to
+67
| inline void impact_neuron_dispatch( | ||
| knp::neuron_traits::neuron_parameters<knp::neuron_traits::LIFNeuron> &neuron, | ||
| const knp::core::messaging::SynapticImpact &impact, bool is_forcing) | ||
| { | ||
| lif::impact_neuron_impl(neuron, impact, is_forcing); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * @brief Calculate post impact state of single neuron. | ||
| * @param neuron Neuron. | ||
| * @return Should neuron produce spike or should not. | ||
| */ | ||
| inline bool calculate_post_impact_single_neuron_state_dispatch( | ||
| knp::neuron_traits::neuron_parameters<knp::neuron_traits::LIFNeuron> &neuron) | ||
| { | ||
| return lif::calculate_post_impact_single_neuron_state_impl(neuron); | ||
| } |
Contributor
There was a problem hiding this comment.
Такое ощущение, что тут эти функции лишние: они не делают ничего, только вызывают другие функции.
Comment on lines
+5
to
+7
| * @date 08.12.2025 | ||
| * @license Apache 2.0 | ||
| * @copyright © 2025 AO Kaspersky Lab |
| { | ||
| switch (impact.synapse_type_) | ||
| { | ||
| case knp::synapse_traits::OutputType::EXCITATORY: |
Contributor
There was a problem hiding this comment.
Почему только один тип синапса?
| } | ||
| else | ||
| { | ||
| neuron.refract_counter_--; |
| auto group0 = nodes_group.getGroup(population_name).getGroup("0"); | ||
| const size_t group_size = nodes_group.getGroup(population_name).getDataSet("node_id").getDimensions().at(0); | ||
|
|
||
| // TODO: Load default neuron from JSON file. |
| /** | ||
| * @brief Default value for leak coefficient. | ||
| */ | ||
| constexpr static float leak_coefficient_ = 1; |
Contributor
There was a problem hiding this comment.
1?
И см. выше - если он больше 1?
Над дописать коммент, хотя бы, и сделать проверку, а лучше сделать так, чтобы by design нельзя было сделать нейрон, уходящий в разнос, просто неправильно задав этот коэффициент.
|
|
||
| /** | ||
| * @brief Refract counter. On neuron activation, counter is set to refract_period and decremented on each step. | ||
| * Incoming impacts are ignored if refract_counter > 0. |
Contributor
There was a problem hiding this comment.
А если я его тут установлю меньше нуля?
Comment on lines
+54
to
+61
| struct NeuronLog | ||
| { | ||
| std::vector<float> potential_; | ||
| std::vector<size_t> spikes_; | ||
| }; | ||
|
|
||
|
|
||
| NeuronLog run_lif_neuron( |
Contributor
There was a problem hiding this comment.
А это всё почему бы в knp::testing не засунуть?
| const std::vector<size_t> expected_spikes{1, 5}; | ||
| ASSERT_EQ(result.potential_, expected_potential); | ||
| ASSERT_EQ(result.spikes_, expected_spikes); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.