Skip to content

Added LIF neuron.#189

Open
DavidIkov wants to merge 14 commits intoKasperskyLab:masterfrom
DavidIkov:lif_neuron
Open

Added LIF neuron.#189
DavidIkov wants to merge 14 commits intoKasperskyLab:masterfrom
DavidIkov:lif_neuron

Conversation

@DavidIkov
Copy link
Copy Markdown
Collaborator

No description provided.

@DavidIkov DavidIkov requested a review from artiomn May 7, 2026 19:51
* @kaspersky_support Postnikov D.
* @date 08.12.2025
* @license Apache 2.0
* @copyright © 2025 AO Kaspersky Lab
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Такое ощущение, что тут эти функции лишние: они не делают ничего, только вызывают другие функции.

Comment on lines +5 to +7
* @date 08.12.2025
* @license Apache 2.0
* @copyright © 2025 AO Kaspersky Lab
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
switch (impact.synapse_type_)
{
case knp::synapse_traits::OutputType::EXCITATORY:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему только один тип синапса?

}
else
{
neuron.refract_counter_--;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

/**
* @brief Default value for leak coefficient.
*/
constexpr static float leak_coefficient_ = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А если я его тут установлю меньше нуля?

Comment on lines +54 to +61
struct NeuronLog
{
std::vector<float> potential_;
std::vector<size_t> spikes_;
};


NeuronLog run_lif_neuron(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А это всё почему бы в knp::testing не засунуть?

const std::vector<size_t> expected_spikes{1, 5};
ASSERT_EQ(result.potential_, expected_potential);
ASSERT_EQ(result.spikes_, expected_spikes);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А на загрузку из сонаты?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants