-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from JordyForNow/Encog
Encog
- Loading branch information
Showing
33 changed files
with
1,123 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,9 @@ | |
|
||
# Skip intermediates | ||
**/obj | ||
|
||
# Skip movement files | ||
**.csv | ||
|
||
# Skip model files | ||
**.eg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 11 additions & 9 deletions
20
MotionRecognition/src/Data Transformation/Movement/CountBasedTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
using System; | ||
|
||
namespace MotionRecognition | ||
{ | ||
// Transformer which transforms sample list to downsized sample list based on specific interval. | ||
public class CountBasedTransformer : IntervalBasedTransformer | ||
{ | ||
/* | ||
public class CountBasedTransformer : IntervalBasedTransformer | ||
{ | ||
/* | ||
* Returns a specific count of values from the original sample list, | ||
* count is used to calculate an interval which is used to retrieve samples from the original list. | ||
*/ | ||
public override double[] GetNeuralInput(IntervalBasedTransformerSettings settings) | ||
{ | ||
settings.interval = settings.sampleList.Length / settings.count; | ||
return base.GetNeuralInput(settings); | ||
} | ||
} | ||
public override double[] GetNeuralInput(IntervalBasedTransformerSettings settings) | ||
{ | ||
settings.interval = settings.sampleList.Length / settings.count; | ||
return base.GetNeuralInput(settings); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 40 additions & 38 deletions
78
MotionRecognition/src/Data Transformation/Movement/IntervalBasedTransformer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MotionRecognition | ||
{ | ||
// Settings struct with properties needed for the functions in the transformer. | ||
public struct IntervalBasedTransformerSettings | ||
{ | ||
public Sample<Vector3>[] sampleList; | ||
// Settings struct with properties needed for the functions in the transformer. | ||
public struct IntervalBasedTransformerSettings | ||
{ | ||
public Sample<Vector3>[] sampleList; | ||
|
||
public int interval { get; set; } | ||
public int count | ||
{ | ||
get | ||
{ | ||
return this.interval; | ||
} | ||
set | ||
{ | ||
this.interval = value; | ||
} | ||
} | ||
} | ||
public double interval { get; set; } | ||
public double count | ||
{ | ||
get | ||
{ | ||
return interval; | ||
} | ||
set | ||
{ | ||
interval = value; | ||
} | ||
} | ||
} | ||
|
||
// Transformer which transforms sample list to downsized list based on given count. | ||
public class IntervalBasedTransformer : IMovementTransformer<IntervalBasedTransformerSettings> | ||
{ | ||
// Returns list of doubles filtered from original sample list on a specific interval. | ||
public virtual double[] GetNeuralInput(IntervalBasedTransformerSettings settings) | ||
{ | ||
List<double> values = new List<double>(); | ||
public class IntervalBasedTransformer : IMovementTransformer<IntervalBasedTransformerSettings> | ||
{ | ||
// Returns list of doubles filtered from original sample list on a specific interval. | ||
public virtual double[] GetNeuralInput(IntervalBasedTransformerSettings settings) | ||
{ | ||
List<double> values = new List<double>(); | ||
double inter = settings.interval; | ||
for (int i = 0; i < settings.sampleList.Length; i++) | ||
{ | ||
if (i == Math.Round(inter) || i == 0) | ||
{ | ||
if (i != 0) | ||
inter += settings.interval; | ||
foreach (Vector3 v in settings.sampleList[i].values) | ||
{ | ||
values.AddRange(v.GetTransformerValue()); | ||
} | ||
} | ||
} | ||
|
||
for (int i = 0; i < settings.sampleList.Length; i++) | ||
{ | ||
if (i % settings.interval == 0) | ||
{ | ||
foreach (Vector3 v in settings.sampleList[i].values) | ||
{ | ||
values.AddRange(v.GetTransformerValue()); | ||
|
||
} | ||
} | ||
} | ||
|
||
return values.ToArray(); | ||
} | ||
} | ||
return values.ToArray(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace MotionRecognition | ||
{ | ||
public class EncogException : Exception | ||
{ | ||
|
||
public EncogException(String Message) : base(Message) { } | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
MotionRecognition/src/Exceptions/IncorrectActionOrderException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace MotionRecognition | ||
{ | ||
public class IncorrectActionOrderException : Exception | ||
{ | ||
|
||
public IncorrectActionOrderException(String Message) : base(Message) { } | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
MotionRecognition/src/Exceptions/InvalidNeuronCountException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace MotionRecognition | ||
{ | ||
public class InvalidNeuronCountException : Exception | ||
{ | ||
|
||
public InvalidNeuronCountException(String Message) : base(Message) { } | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
MotionRecognition/src/Exceptions/NoParameterGivenException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace MotionRecognition | ||
{ | ||
public class NoParameterGivenException : Exception | ||
{ | ||
|
||
public NoParameterGivenException(String Message) : base(Message) { } | ||
|
||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
MotionRecognition/src/Exceptions/WrongFileTypeException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace MotionRecognition | ||
{ | ||
public class WrongFileTypeException : Exception | ||
{ | ||
|
||
public WrongFileTypeException(String Message) : base(Message) { } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.IO; | ||
|
||
namespace MotionRecognition | ||
{ | ||
public static class BaseTrainHelper | ||
{ | ||
|
||
// Helper function which returns the total number of files in a directory. | ||
public static int GetFileCount(string dataDirectory) | ||
{ | ||
// Get total number of '.csv' files inside Directory. | ||
return Directory.GetFiles( | ||
dataDirectory, | ||
"*.csv*", | ||
SearchOption.TopDirectoryOnly | ||
).Length; | ||
} | ||
|
||
// This helper function copies a 1D array into a 2D array. | ||
public static void Project1DInto2D(double[] source, ref double[][] dest, int index) | ||
{ | ||
double[] temp = new double[source.Length]; | ||
|
||
for (int i = 0; i < source.Length; i++) | ||
{ | ||
temp[i] = source[i]; | ||
} | ||
|
||
dest[index] = temp; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.