Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
Enum consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
okozelsk committed Jan 6, 2019
1 parent ec27d66 commit c8ad58f
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 296 deletions.
354 changes: 92 additions & 262 deletions Demo/DemoConsoleApp/DemoSettings.xml

Large diffs are not rendered by default.

16 changes: 0 additions & 16 deletions RCNet/Neural/Activation/ActivationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,6 @@ namespace RCNet.Neural.Activation
/// </summary>
public static class ActivationFactory
{
//Constants
/// <summary>
/// Activation function output signal
/// </summary>
public enum FunctionOutputSignalType
{
/// <summary>
/// Function fires spikes when firing condition is met
/// </summary>
Spike,
/// <summary>
/// Function has continuous analog output
/// </summary>
Analog
};

/// <summary>
/// Returns the instance of the activation function settings
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion RCNet/Neural/Activation/AnalogActivationFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class AnalogActivationFunction : IActivationFunction
/// <summary>
/// Type of the output signal
/// </summary>
public ActivationFactory.FunctionOutputSignalType OutputSignalType { get { return ActivationFactory.FunctionOutputSignalType.Analog; } }
public CommonEnums.NeuronSignalType OutputSignalType { get { return CommonEnums.NeuronSignalType.Analog; } }

/// <summary>
/// Output signal range
Expand Down
2 changes: 1 addition & 1 deletion RCNet/Neural/Activation/IActivationFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface IActivationFunction
/// <summary>
/// Type of the output signal
/// </summary>
ActivationFactory.FunctionOutputSignalType OutputSignalType { get; }
CommonEnums.NeuronSignalType OutputSignalType { get; }

/// <summary>
/// Output range
Expand Down
2 changes: 1 addition & 1 deletion RCNet/Neural/Activation/ODESpikingMembrane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int numOfEvolvingVars
/// <summary>
/// Type of the output
/// </summary>
public ActivationFactory.FunctionOutputSignalType OutputSignalType { get { return ActivationFactory.FunctionOutputSignalType.Spike; } }
public CommonEnums.NeuronSignalType OutputSignalType { get { return CommonEnums.NeuronSignalType.Spike; } }

/// <summary>
/// Output signal range
Expand Down
2 changes: 1 addition & 1 deletion RCNet/Neural/Activation/SimpleIF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int refractoryPeriods
/// <summary>
/// Type of the output
/// </summary>
public ActivationFactory.FunctionOutputSignalType OutputSignalType { get { return ActivationFactory.FunctionOutputSignalType.Spike; } }
public CommonEnums.NeuronSignalType OutputSignalType { get { return CommonEnums.NeuronSignalType.Spike; } }

/// <summary>
/// Output signal range
Expand Down
15 changes: 15 additions & 0 deletions RCNet/Neural/CommonEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ public enum InputFeedingType
Patterned
}

/// <summary>
/// Types of the neuron's output signal
/// </summary>
public enum NeuronSignalType
{
/// <summary>
/// Neuron fires spike when firing condition is met
/// </summary>
Spike,
/// <summary>
/// Neuron has continuous analog output signal
/// </summary>
Analog
};


/// <summary>
/// Supported task types.
Expand Down
4 changes: 2 additions & 2 deletions RCNet/Neural/Network/SM/Neuron/AnalogNeuron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class AnalogNeuron : INeuron
/// Type of the output signal (spike or analog)
/// This neuron is analog
/// </summary>
public ActivationFactory.FunctionOutputSignalType OutputType { get { return _activation.OutputSignalType; } }
public CommonEnums.NeuronSignalType OutputType { get { return _activation.OutputSignalType; } }

/// <summary>
/// Output signal range
Expand Down Expand Up @@ -104,7 +104,7 @@ double retainmentRatio
Role = role;
Bias = bias;
//Check whether function is analog
if (activation.OutputSignalType != ActivationFactory.FunctionOutputSignalType.Analog)
if (activation.OutputSignalType != CommonEnums.NeuronSignalType.Analog)
{
throw new ArgumentException("Activation function is not analog.", "activation");
}
Expand Down
2 changes: 1 addition & 1 deletion RCNet/Neural/Network/SM/Neuron/INeuron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface INeuron
/// <summary>
/// Type of the output signal (spike or analog)
/// </summary>
ActivationFactory.FunctionOutputSignalType OutputType { get; }
CommonEnums.NeuronSignalType OutputType { get; }

/// <summary>
/// Output signal range
Expand Down
2 changes: 1 addition & 1 deletion RCNet/Neural/Network/SM/Neuron/InputNeuron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class InputNeuron : INeuron
/// Type of the output signal (spike or analog)
/// Input neuron is an analog neuron.
/// </summary>
public ActivationFactory.FunctionOutputSignalType OutputType { get { return ActivationFactory.FunctionOutputSignalType.Analog; } }
public CommonEnums.NeuronSignalType OutputType { get { return CommonEnums.NeuronSignalType.Analog; } }

/// <summary>
/// Output signal range
Expand Down
4 changes: 2 additions & 2 deletions RCNet/Neural/Network/SM/Neuron/SpikingNeuron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SpikingNeuron : INeuron
/// Type of the output signal (spike or analog)
/// This neuron is spiking.
/// </summary>
public ActivationFactory.FunctionOutputSignalType OutputType { get { return _activation.OutputSignalType; } }
public CommonEnums.NeuronSignalType OutputType { get { return _activation.OutputSignalType; } }

/// <summary>
/// Output signal range
Expand Down Expand Up @@ -110,7 +110,7 @@ double bias
Role = role;
Bias = bias;
//Check whether function is spiking
if (activation.OutputSignalType != ActivationFactory.FunctionOutputSignalType.Spike)
if (activation.OutputSignalType != CommonEnums.NeuronSignalType.Spike)
{
throw new ArgumentException("Activation function is not spiking.", "activation");
}
Expand Down
4 changes: 2 additions & 2 deletions RCNet/Neural/Network/SM/ReservoirStructure/Reservoir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public Reservoir(StateMachineSettings.ReservoirInstanceDefinition instanceDefini
RetainmentRate = 0,
UseAsPredictor = false
};
if(neuronParams.Activation.OutputSignalType == ActivationFactory.FunctionOutputSignalType.Analog)
if(neuronParams.Activation.OutputSignalType == CommonEnums.NeuronSignalType.Analog)
{
analogActivationIdxs.Add(idx);
}
Expand Down Expand Up @@ -139,7 +139,7 @@ public Reservoir(StateMachineSettings.ReservoirInstanceDefinition instanceDefini
{
NeuronPlacement placement = new NeuronPlacement(neuronGlobalFlatIdx, poolID, neuronPoolFlatIdx, neuronParamsCollection[neuronPoolFlatIdx].GroupID, poolSettings.Dim.X + x, poolSettings.Dim.Y + y, poolSettings.Dim.Z + z);
//Neuron instance
if (neuronParamsCollection[neuronPoolFlatIdx].Activation.OutputSignalType == ActivationFactory.FunctionOutputSignalType.Spike)
if (neuronParamsCollection[neuronPoolFlatIdx].Activation.OutputSignalType == CommonEnums.NeuronSignalType.Spike)
{
//Spiking neuron
poolNeurons[neuronPoolFlatIdx] = new SpikingNeuron(placement,
Expand Down
8 changes: 4 additions & 4 deletions RCNet/Neural/Network/SM/Synapse/BaseSynapse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ double weight
if (SourceNeuron.Role == CommonEnums.NeuronRole.Input)
{
//Source is input neuron
if (TargetNeuron.OutputType == Activation.ActivationFactory.FunctionOutputSignalType.Spike)
if (TargetNeuron.OutputType == CommonEnums.NeuronSignalType.Spike)
{
//Target is spiking
//Ensure positive weight
Expand All @@ -107,10 +107,10 @@ double weight
else
{
//Source is reservoir neuron
if (SourceNeuron.OutputType == Activation.ActivationFactory.FunctionOutputSignalType.Spike)
if (SourceNeuron.OutputType == CommonEnums.NeuronSignalType.Spike)
{
//Source reservoir neuron is spiking
if (TargetNeuron.OutputType == Activation.ActivationFactory.FunctionOutputSignalType.Spike)
if (TargetNeuron.OutputType == CommonEnums.NeuronSignalType.Spike)
{
//Target is also spiking
//Weight dependent on source neuron role
Expand All @@ -132,7 +132,7 @@ double weight
else
{
//Source reservoir neuron is analog
if (TargetNeuron.OutputType == Activation.ActivationFactory.FunctionOutputSignalType.Spike)
if (TargetNeuron.OutputType == CommonEnums.NeuronSignalType.Spike)
{
//Target is spiking
//Weight dependent on source neuron role
Expand Down
4 changes: 2 additions & 2 deletions RCNet/Neural/Network/SM/Synapse/DynamicSynapse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ double tauDecay
_tauFacilitation = tauFacilitation;
_tauRecovery = tauRecovery;
_restingEfficacy = restingEfficacy;
_applyPreSynaptic = (SourceNeuron.OutputType == Activation.ActivationFactory.FunctionOutputSignalType.Spike);
_applyPreSynaptic = (SourceNeuron.OutputType == CommonEnums.NeuronSignalType.Spike);
_efficacyUtilization = _restingEfficacy;
_efficacyAvailableFraction = 1;
_tauDecay = tauDecay;
_applyPostSynaptic = (TargetNeuron.OutputType == Activation.ActivationFactory.FunctionOutputSignalType.Spike);
_applyPostSynaptic = (TargetNeuron.OutputType == CommonEnums.NeuronSignalType.Spike);
return;
}

Expand Down

0 comments on commit c8ad58f

Please sign in to comment.