Skip to content

Commit 52f653c

Browse files
committed
Network optimisation using references instead of regular arguments has been made
1 parent b6e9279 commit 52f653c

File tree

1,005 files changed

+21
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,005 files changed

+21
-15
lines changed

NeuralNetwork.sln

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1010
.editorconfig = .editorconfig
1111
EndProjectSection
1212
EndProject
13-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeuralNetworkExample_FishersIris", "NeuralNetworkExample\NeuralNetworkExample_FishersIris.csproj", "{772B7312-F432-4378-B7BD-726219761D1A}"
13+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NeuralNetworkExample_FishersIris", "NeuralNetworkExample_FishersIris\NeuralNetworkExample_FishersIris.csproj", "{6BB57525-8D05-4A27-ACBF-107781291040}"
1414
EndProject
15-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NeuralNetworkExample_ImageRecognition", "NeuralNetworkExample2\NeuralNetworkExample_ImageRecognition.csproj", "{B3CA65D2-FE1C-4494-8C24-AFFB1408E6E2}"
15+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NeuralNetworkExample_ImageRecognition", "NeuralNetworkExample_ImageRecognition\NeuralNetworkExample_ImageRecognition.csproj", "{B3CA65D2-FE1C-4494-8C24-AFFB1408E6E2}"
1616
EndProject
1717
Global
1818
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -24,10 +24,10 @@ Global
2424
{F6FC81C0-24B0-4E9E-BA25-A595DB36AD7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
2525
{F6FC81C0-24B0-4E9E-BA25-A595DB36AD7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
2626
{F6FC81C0-24B0-4E9E-BA25-A595DB36AD7C}.Release|Any CPU.Build.0 = Release|Any CPU
27-
{772B7312-F432-4378-B7BD-726219761D1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28-
{772B7312-F432-4378-B7BD-726219761D1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
29-
{772B7312-F432-4378-B7BD-726219761D1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
30-
{772B7312-F432-4378-B7BD-726219761D1A}.Release|Any CPU.Build.0 = Release|Any CPU
27+
{6BB57525-8D05-4A27-ACBF-107781291040}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{6BB57525-8D05-4A27-ACBF-107781291040}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{6BB57525-8D05-4A27-ACBF-107781291040}.Release|Any CPU.ActiveCfg = Release|Any CPU
30+
{6BB57525-8D05-4A27-ACBF-107781291040}.Release|Any CPU.Build.0 = Release|Any CPU
3131
{B3CA65D2-FE1C-4494-8C24-AFFB1408E6E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
3232
{B3CA65D2-FE1C-4494-8C24-AFFB1408E6E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
3333
{B3CA65D2-FE1C-4494-8C24-AFFB1408E6E2}.Release|Any CPU.ActiveCfg = Release|Any CPU

NeuralNetwork/NeuralNetwork.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ public void SaveNetwork(string pathAndName)
181181

182182
#region NeuralNetwork Run
183183
/// <summary>
184-
/// Runs the network and returns Output neurons with the struct Neuron[].
184+
/// Runs the network and returns reference to Output neurons with the struct Neuron[].
185185
/// </summary>
186186
/// <param name="inputValues">This is array that contains input set.</param>
187-
/// <returns>Neuron[]</returns>
188-
public virtual Neuron[] RunNetwork(double[] inputValues)
187+
/// <returns>Neuron[] reference</returns>
188+
public virtual ref Neuron[] RunNetwork(double[] inputValues)
189189
{
190190
//INPUT neurons assignment
191191
for (j = 0; j < inputValues.Length; ++j)
@@ -205,7 +205,7 @@ public virtual Neuron[] RunNetwork(double[] inputValues)
205205
}
206206
}
207207

208-
return Network[Network.GetLength(0) - 1];
208+
return ref Network[Network.GetLength(0) - 1];
209209
}
210210

211211
//===========================================================================================================
@@ -229,7 +229,7 @@ public virtual void TeachNetwork(double[] ideal)
229229
//Calculating Delta(HIDDEN) for HIDDEN neurons the NeuralNetwork
230230
for (i = LayersCount - 2; i >= 1; --i) //Start - from the last HIDDEN layer | End - to the firs HIDDEN layer
231231
for (j = 0; j < Network[i].Length; ++j)
232-
deltaNetwork[i][j].value = DeltaHidden(Network[i][j].weights, deltaNetwork[i + 1], Network[i][j].value);
232+
deltaNetwork[i][j].value = DeltaHidden(Network[i][j].weights, ref deltaNetwork[i + 1], Network[i][j].value);
233233

234234
//Calculating delta of all the weights to change them
235235
for (i = LayersCount - 2; i >= 0; --i) // Start - from the last HIDDEN layer | End - to the firs layer (INPUT)
@@ -263,7 +263,7 @@ private double DeltaOut(double outIdeal, double outActual)
263263
{
264264
return ((outIdeal - outActual) * SigmoidError(outActual));
265265
}
266-
private double DeltaHidden(double[] weights, Neuron[] delta, double output)
266+
private double DeltaHidden(double[] weights, ref Neuron[] delta, double output)
267267
{
268268
double actualSum = 0;
269269

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)