Skip to content

Commit

Permalink
Merge pull request #11 from JordyForNow/Encog
Browse files Browse the repository at this point in the history
Encog
  • Loading branch information
Velikss authored Jan 14, 2020
2 parents 91cb829 + a73cceb commit 7c01210
Show file tree
Hide file tree
Showing 33 changed files with 1,123 additions and 242 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ csharp_space_after_dot = false
# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true

# IDE0060: Remove unused parameter
dotnet_code_quality_unused_parameters = all:suggestion

[*.cs]

# CS0659: Type overrides Object.Equals(object o) but does not override Object.GetHashCode()
Expand Down
28 changes: 26 additions & 2 deletions .github/workflows/building.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ on:


jobs:
build:

build_3-1-100:
runs-on: windows-latest

steps:
Expand All @@ -26,3 +25,28 @@ jobs:
dotnet-version: 3.1.100
- name: Build with dotnet
run: dotnet build

build-_3-0-100:
runs-on: windows-latest

steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.0.100
- name: Build with dotnet
run: dotnet build

build_2-2-103:
runs-on: windows-latest

steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.2.103
- name: Build with dotnet
run: dotnet build

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@

# Skip intermediates
**/obj

# Skip movement files
**.csv

# Skip model files
**.eg
15 changes: 10 additions & 5 deletions MotionRecognition.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sandbox", "Sandbox\Sandbox.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "UnitTests\UnitTests.csproj", "{06B71FFE-B063-4C40-A78B-0C135EAEDCD9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MotionRecognitionHelper", "MotionRecognitionHelper\MotionRecognitionHelper.csproj", "{CAF5CCD8-B455-4543-93A5-E238FD710832}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E6B9092A-65AE-4622-BC11-871EF076515E}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MotionRecognitionHelper", "MotionRecognitionHelper\MotionRecognitionHelper.csproj", "{1E10926B-0E00-42FD-B983-23BA111CFEDB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -28,10 +33,10 @@ Global
{06B71FFE-B063-4C40-A78B-0C135EAEDCD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06B71FFE-B063-4C40-A78B-0C135EAEDCD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06B71FFE-B063-4C40-A78B-0C135EAEDCD9}.Release|Any CPU.Build.0 = Release|Any CPU
{CAF5CCD8-B455-4543-93A5-E238FD710832}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CAF5CCD8-B455-4543-93A5-E238FD710832}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CAF5CCD8-B455-4543-93A5-E238FD710832}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CAF5CCD8-B455-4543-93A5-E238FD710832}.Release|Any CPU.Build.0 = Release|Any CPU
{1E10926B-0E00-42FD-B983-23BA111CFEDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1E10926B-0E00-42FD-B983-23BA111CFEDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1E10926B-0E00-42FD-B983-23BA111CFEDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1E10926B-0E00-42FD-B983-23BA111CFEDB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
9 changes: 9 additions & 0 deletions MotionRecognition/MotionRecognition.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Remove="src\DataLoader\**" />
<Compile Remove="src\DataMutation\**" />
<EmbeddedResource Remove="src\DataLoader\**" />
<EmbeddedResource Remove="src\DataMutation\**" />
<None Remove="src\DataLoader\**" />
<None Remove="src\DataMutation\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="encog-dotnet-core" Version="3.4.0" />
</ItemGroup>
Expand Down
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public enum LeapMotionJoint
// Settings struct with properties needed for the functions in the transformer.
public struct ImageTransformerSettings
{
public int size;
public uint size;
public Sample<Vector3>[] samples;

// Which items are used of the sample column list.
Expand Down
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();
}
}
}
11 changes: 11 additions & 0 deletions MotionRecognition/src/Exceptions/EncogException.cs
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 MotionRecognition/src/Exceptions/IncorrectActionOrderException.cs
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 MotionRecognition/src/Exceptions/InvalidNeuronCountException.cs
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 MotionRecognition/src/Exceptions/NoParameterGivenException.cs
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 MotionRecognition/src/Exceptions/WrongFileTypeException.cs
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) { }

}
}
33 changes: 33 additions & 0 deletions MotionRecognition/src/Recognizer/BaseTrainHelper.cs
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;
}

}
}
Loading

0 comments on commit 7c01210

Please sign in to comment.