You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PruneIncremental class runs into errors when running with multiple threads. The _hiddenCounts and _pattern are shared across threads.
The hidden counts are modified by each thread in IncreaseHiddenCounts when a RequestNextTask call occurs. The same _pattern object is used by all threads to generate a network. So multiple threads trying to generate a network at the same time can lead to unintended hidden layers being created.
I think these objects could use a lock around the critical sections.
/// <summary>
/// Generate a network according to the current hidden layer counts.
/// </summary>
///
/// <returns>The network based on current hidden layer counts.</returns>
private BasicNetwork GenerateNetwork()
{
BasicNetwork network = null;
lock (_pattern)
{
_pattern.Clear();
lock (this._hiddenCounts.SyncRoot)
{
foreach (int element in _hiddenCounts)
{
if (element > 0)
{
_pattern.AddHiddenLayer(element);
}
}
}
network = (BasicNetwork)_pattern.Generate();
}
return network;
}
/// <summary>
/// Increase the hidden layer counts according to the hidden layer
/// parameters. Increase the first hidden layer count by one, if it is maxed
/// out, then set it to zero and increase the next hidden layer.
/// </summary>
///
/// <returns>False if no more increases can be done, true otherwise.</returns>
private bool IncreaseHiddenCounts()
{
lock (_hiddenCounts.SyncRoot)
{
int i = 0;
do
{
HiddenLayerParams param = _hidden[i];
_hiddenCounts[i]++;
// is this hidden layer still within the range?
if (_hiddenCounts[i] <= param.Max)
{
return true;
}
// increase the next layer if we've maxed out this one
_hiddenCounts[i] = param.Min;
i++;
} while (i < _hiddenCounts.Length);
}
// can't increase anymore, we're done!
return false;
}
The text was updated successfully, but these errors were encountered:
The PruneIncremental class runs into errors when running with multiple threads. The _hiddenCounts and _pattern are shared across threads.
The hidden counts are modified by each thread in IncreaseHiddenCounts when a RequestNextTask call occurs. The same _pattern object is used by all threads to generate a network. So multiple threads trying to generate a network at the same time can lead to unintended hidden layers being created.
I think these objects could use a lock around the critical sections.
The text was updated successfully, but these errors were encountered: