problem sets: chess sets
This commit is contained in:
29
include/NeuralNetwork/ProblemSets/Chess.h
Normal file
29
include/NeuralNetwork/ProblemSets/Chess.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <random>
|
||||
|
||||
namespace NeuralNetwork {
|
||||
namespace ProblemSets {
|
||||
typedef std::pair<std::vector<float>, std::vector<float>> TrainingPattern;
|
||||
|
||||
std::vector<TrainingPattern> Chess3X3(float min, std::size_t patterns) {
|
||||
std::vector<TrainingPattern> ret;
|
||||
std::mt19937 _generator(rand());
|
||||
std::uniform_real_distribution<> _distribution(min,1);
|
||||
float step = (1.0-min)/3.0;
|
||||
for(std::size_t i=0;i<patterns;i++) {
|
||||
float x=_distribution(_generator);
|
||||
float y=_distribution(_generator);
|
||||
int classX= (static_cast<int>((x-min)/step) + static_cast<int>((y-min)/step)) % 2;
|
||||
if(classX == 0) {
|
||||
ret.push_back({{x,y},{min}});
|
||||
} else {
|
||||
ret.push_back({{x,y},{1.0}});
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user