This commit is contained in:
Asrın Doğan 2019-12-13 20:04:33 +03:00
parent 70675843c3
commit dc43ce7a29
2 changed files with 49 additions and 19 deletions

19
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}

View File

@ -33,7 +33,14 @@ float RandomFloat(int min, int max)
float Fire(); float Fire();
}; };
Sinaps::Sinaps() { weight = value = bias = 0.0; } Sinaps::Sinaps()
{
weight = value = bias = 0.0;
std::clog << "Create Sinaps: Weight = " << weight
<< " Value = " << value
<< " Bias = " << bias << "\n";
}
Sinaps::~Sinaps() Sinaps::~Sinaps()
{ {
std::clog << "Delete Sinaps: Weight = " << weight std::clog << "Delete Sinaps: Weight = " << weight
@ -104,37 +111,41 @@ float RandomFloat(int min, int max)
bool Noron::SetForwards(Sinaps *newForwards, int size) bool Noron::SetForwards(Sinaps *newForwards, int size)
{ {
forwards = new Sinaps[size]; std::clog << "SetForwards: Allocating Memory of Size " << size << "\n";
forwards = (Sinaps *)new char[sizeof(Sinaps) * size];
if(!forwards) if(!forwards)
{ {
std::clog << "Set Forwards: Memory Couldn't Allocated!" << "\n"; std::clog << "SetForwards: Memory Couldn't Allocated!" << "\n";
return false; return false;
} }
std::clog << "SetForwards: Memory Allocated!" << "\n";
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
*(forwards+i) = *(newForwards+i); *(forwards+i) = *(newForwards+i);
forwardsCount = size; forwardsCount = size;
std::clog << "Set Forwards: Successfull!" << "\n"; std::clog << "SetForwards: Successfull!" << "\n";
return true; return true;
} }
bool Noron::SetIncoming(Sinaps *newIncoming, int size) bool Noron::SetIncoming(Sinaps *newIncoming, int size)
{ {
incoming = new Sinaps[size]; std::clog << "SetIncoming: Allocating Memory of Size " << size << "\n";
incoming = (Sinaps *)new char[sizeof(Sinaps) * size];
if(!incoming) if(!incoming)
{ {
std::clog << "Set Incoming: Memory Couldn't Allocated!" << "\n"; std::clog << "SetIncoming: Memory Couldn't Allocated!" << "\n";
return false; return false;
} }
std::clog << "SetIncoming: Memory Allocated!" << "\n";
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
*(incoming+i) = *(newIncoming+i); *(incoming+i) = *(newIncoming+i);
incomingCount = size; incomingCount = size;
std::clog << "Set Incoming: Successfull!" << "\n"; std::clog << "SetIncoming: Successfull!" << "\n";
return true; return true;
} }
@ -253,7 +264,7 @@ float RandomFloat(int min, int max)
forwardSize = forward -> GetSize(); forwardSize = forward -> GetSize();
std::clog << "Call SetForward: Creating Sinaps Set with Number of " << (size * forwardSize) << "\n"; std::clog << "Call SetForward: Creating Sinaps Set with Number of " << (size * forwardSize) << "\n";
sinapses = new Sinaps[size * forwardSize]; sinapses = (Sinaps *)new char[sizeof(Sinaps) * size * forwardSize];
if(!sinapses) if(!sinapses)
{ {
@ -295,7 +306,7 @@ float RandomFloat(int min, int max)
Sinaps *sinapses = NULL; Sinaps *sinapses = NULL;
std::clog << "Call SetIncoming: Creating Sinaps Set with Number of " << backwardsNeuronCount << "\n"; std::clog << "Call SetIncoming: Creating Sinaps Set with Number of " << backwardsNeuronCount << "\n";
sinapses = new Sinaps[backwardsNeuronCount]; sinapses = (Sinaps *)new char[sizeof(Sinaps) * backwardsNeuronCount];
if(!sinapses) if(!sinapses)
{ {
@ -322,7 +333,7 @@ float RandomFloat(int min, int max)
bool Katman::SetNoron(Noron *newNeurons, int size) bool Katman::SetNoron(Noron *newNeurons, int size)
{ {
std::clog << "Call SetNoron: Creating Neurons with Number of " << size << "\n"; std::clog << "Call SetNoron: Creating Neurons with Number of " << size << "\n";
neurons = new Noron[size]; neurons = (Noron *) new char[sizeof(Noron) * size];
if(!neurons) if(!neurons)
{ {
@ -481,7 +492,7 @@ float RandomFloat(int min, int max)
{ {
std::clog << "Call SetHiddenLayerNeurons: Size of " << size << " at Index of " << index << "\n"; std::clog << "Call SetHiddenLayerNeurons: Size of " << size << " at Index of " << index << "\n";
std::clog << "Call SetHiddenLayerNeurons: Creating " << size << " Neurons!" << "\n"; std::clog << "Call SetHiddenLayerNeurons: Creating " << size << " Neurons!" << "\n";
Noron *neurons = new Noron[size]; Noron *neurons = (Noron *) new char[sizeof(Noron) * size];
if(!neurons) if(!neurons)
{ {
@ -497,7 +508,7 @@ float RandomFloat(int min, int max)
{ {
std::clog << "Call SetInputNeurons: Size of " << size << "\n"; std::clog << "Call SetInputNeurons: Size of " << size << "\n";
std::clog << "Call SetInputNeurons: Creating " << size << " Neurons!" << "\n"; std::clog << "Call SetInputNeurons: Creating " << size << " Neurons!" << "\n";
Noron *neurons = new Noron[size]; Noron *neurons = (Noron *) new char[sizeof(Noron) * size];
if(!neurons) if(!neurons)
{ {
@ -513,7 +524,7 @@ float RandomFloat(int min, int max)
{ {
std::clog << "Call SetInputNeurons: Size of " << size << "\n"; std::clog << "Call SetInputNeurons: Size of " << size << "\n";
std::clog << "Call SetInputNeurons: Creating " << size << " Neurons!" << "\n"; std::clog << "Call SetInputNeurons: Creating " << size << " Neurons!" << "\n";
Noron *neurons = new Noron[size]; Noron *neurons = (Noron *) new char[sizeof(Noron) * size];
if(!neurons) if(!neurons)
{ {
@ -612,14 +623,14 @@ int main(int argc, char const *argv[])
network.SetOutputNeurons(1); network.SetOutputNeurons(1);
network.ConnectLayers(); network.ConnectLayers();
network.RandomizeNetworkValues();
network.SetInput(0, 1);
std::cout << "m1\n"; std::cout << "m1\n";
network.RandomizeNetworkValues();
network.FireNetwork();
std::cout << "m2\n"; std::cout << "m2\n";
std::cout << network.GetOutputValue(0) << "\n";
// network.SetInput(0, 1);
std::cout << "m3\n"; std::cout << "m3\n";
// network.FireNetwork();
// std::cout << network.GetOutputValue(0) << "\n";
return 0; return 0;
} }