Skip to content

Commit

Permalink
Add call to registration from the NeatGenomeFactory, preventing the e…
Browse files Browse the repository at this point in the history
…nd user from needing to make a separate call.
  • Loading branch information
naigonakoii committed Jun 11, 2019
1 parent 85e671e commit 65f6d22
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/SharpNeatLib/Genomes/Neat/NeatGenomeFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ public NeatGenomeFactory(int inputNeuronCount, int outputNeuronCount)

_genomeIdGenerator = new UInt32IdGenerator();
_innovationIdGenerator = new UInt32IdGenerator();

if (neatGenomeParams.ActivationFn != null)
{
// Register the activation function with the library if it is specified.
ActivationFunctionRegistry.RegisterActivationFunction(neatGenomeParams.ActivationFn);
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public static class ActivationFunctionRegistry
/// </summary>
public static void RegisterActivationFunction(IActivationFunction function)
{
_registeredActivationFunctions.Add(function.FunctionId, function);
if (!_registeredActivationFunctions.ContainsKey(function.FunctionId))
{
_registeredActivationFunctions.Add(function.FunctionId, function);
}
}
#endregion // Static Public Methods
}
Expand Down

0 comments on commit 65f6d22

Please sign in to comment.