This repository was archived by the owner on May 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSpikingInputNeuron.cs
More file actions
91 lines (79 loc) · 2.54 KB
/
SpikingInputNeuron.cs
File metadata and controls
91 lines (79 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using RCNet.Neural.Activation;
using System;
namespace RCNet.Neural.Network.SM.Preprocessing.Neuron
{
/// <summary>
/// Implements the input spiking neuron.
/// </summary>
/// <remarks>
/// The input spiking neuron is a special case of the neuron without an activation function.
/// Its purpose is to provide a spiking input for the reservoir's synapses.
/// </remarks>
[Serializable]
public class SpikingInputNeuron : INeuron
{
//Attribute properties
/// <inheritdoc/>
public NeuronLocation Location { get; }
/// <inheritdoc/>
public NeuronStatistics Statistics { get; }
/// <inheritdoc/>
public NeuronOutputData OutputData { get; }
//Attributes
private double _inputSpike;
//Constructor
/// <summary>
/// Creates an initialized instance.
/// </summary>
/// <param name="location">Neuron's location</param>
public SpikingInputNeuron(NeuronLocation location)
{
Location = location;
Statistics = new NeuronStatistics();
OutputData = new NeuronOutputData();
Reset(false);
return;
}
//Properties
/// <inheritdoc/>
public NeuronType Type { get { return NeuronType.Input; } }
/// <inheritdoc/>
public ActivationType TypeOfActivation { get { return ActivationType.Spiking; } }
//Methods
/// <inheritdoc/>
public void Reset(bool statistics)
{
_inputSpike = 0;
OutputData.Reset();
if (statistics)
{
Statistics.Reset();
}
return;
}
/// <inheritdoc/>
public void NewStimulation(double iStimuli, double rStimuli)
{
_inputSpike = iStimuli > 0 ? 1d : 0d;
return;
}
/// <inheritdoc/>
public void Recompute(bool collectStatistics)
{
if (OutputData._spikingSignal > 0)
{
//Spike during previous cycle, so reset the counter
OutputData._afterFirstSpike = true;
OutputData._spikeLeak = 0;
}
++OutputData._spikeLeak;
OutputData._spikingSignal = _inputSpike;
//Statistics
if (collectStatistics)
{
Statistics.Update(_inputSpike, 0d, _inputSpike, _inputSpike, 0, _inputSpike);
}
return;
}
}//SpikingInputNeuron
}//Namespace