summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthewsotoudeh <matthewsot@outlook.com>2016-04-12 18:10:33 -0700
committermatthewsotoudeh <matthewsot@outlook.com>2016-04-12 18:10:33 -0700
commitf9fea74563de525068331338bf5c9c7dccb0d30f (patch)
tree3a2ec8b6377d278fb65ad46bfb6b560d3ccb85fe
parent28c09ec5bc48463bb279cc82a97866f7bfc9c4f3 (diff)
added a value for trainingsetrandomization
-rw-r--r--NImg/NImg/Compressor.cs6
-rw-r--r--NImg/NImg/Loader.cs4
-rw-r--r--README.md4
3 files changed, 10 insertions, 4 deletions
diff --git a/NImg/NImg/Compressor.cs b/NImg/NImg/Compressor.cs
index 078f8aa..c611cb4 100644
--- a/NImg/NImg/Compressor.cs
+++ b/NImg/NImg/Compressor.cs
@@ -23,6 +23,7 @@ namespace NImg
var colorIndexTolerance = 5;
var trainingRounds = 5;
var maxTrainingSets = -1;
+ var trainingSetRandomization = 0;
if (File.Exists("nimg.config"))
{
@@ -58,12 +59,15 @@ namespace NImg
case "maxTrainingSets":
maxTrainingSets = int.Parse(parts[1]);
break;
+ case "trainingSetRandomization":
+ trainingSetRandomization = int.Parse(parts[1]);
+ break;
}
}
}
}
- var trainingSets = Loader.LoadTrainingSets(files, inputPixels, maxTrainingSets);
+ var trainingSets = Loader.LoadTrainingSets(files, inputPixels, maxTrainingSets, trainingSetRandomization);
Network network = new Network(inputPixels * 3, innerLayers, neuronsPerLayer, 3);
var biasNeurons = 1;
diff --git a/NImg/NImg/Loader.cs b/NImg/NImg/Loader.cs
index 2d7f671..f78d59d 100644
--- a/NImg/NImg/Loader.cs
+++ b/NImg/NImg/Loader.cs
@@ -7,7 +7,7 @@ namespace NImg
{
static class Loader
{
- public static TrainingSet[] LoadTrainingSets(string[] paths, int inputPixels = 3, int maxTrainingSets = -1)
+ public static TrainingSet[] LoadTrainingSets(string[] paths, int inputPixels = 3, int maxTrainingSets = -1, int trainingSetRandomization = 1)
{
var trainingSets = new List<TrainingSet>();
foreach (var path in paths)
@@ -16,7 +16,7 @@ namespace NImg
using (var image = new Bitmap(path))
{
var sets = 0;
- if (maxTrainingSets != -1)
+ if (maxTrainingSets != -1 && trainingSetRandomization == 1)
{
for (var i = 0; i < maxTrainingSets; i++)
{
diff --git a/README.md b/README.md
index e72d547..6709c57 100644
--- a/README.md
+++ b/README.md
@@ -26,6 +26,7 @@ writeTolerance 8
colorIndexTolerance 5
trainingRounds 50000
maxTrainingSets 20
+trainingSetRandomization 0
```
Compressed into an NIMG file of **48,874 bytes**. The ``.nimg`` file (after being converted losslessly to a PNG):
@@ -91,7 +92,8 @@ colorIndexBytes [ 0 => Disable the color dictionary, 1 => maximum 239 distinct c
writeTolerance [ The maximum difference between the predicted color and the actual color. Lower = large file size, less lossy ]
colorIndexTolerance [ The maximum difference between the pixel color and the color stored in the dictionary. Lower = larger file size, less lossy ]
trainingRounds [ The number of rounds to train the network for. Lower = higher file size, quicker ]
-maxTrainingSets [ The number of training sets to create. Lower = quicker, potentially better-fitted network ]
+maxTrainingSets [ The number of training sets to create. 0 = Unlimited. Lower = quicker, potentially better-fitted network ]
+trainingSetRandomization [ If maxTrainingSets > 0: 0 -> pull sets sequentially from the top left of the image, 1 -> pull sets randomly from the image ]
```
See above for an example ``nimg.config``. Any lines may be removed and will be filled in with default values.
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback