Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions FirstClassEdem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Include<iostream>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capital I here :P

#include<Math.h>

Class FirstCLassEdem {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in name, you have a capital L in Class

int FirstNumber, SecondNumber;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable names should start with lower case (ie firstNumber)

public double RandomFunction (int Parameter1, int Parameter2);
} FirstUse


double FirstClass::RandomFunction (int AddValue, int MultipValue){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function names should also start with lower case (ie randomFunction)
Parameter variable names as well
Add a space after the parameters and before the curly bracket ("int multiplyValue)(space here){")
In C++, usually you should declare your class (and function prototypes) within a header file (.h) and define the class within the cpp file (.cpp), but I didn't explain that in the exercise so that was my fault

return ( (3.14159)*(MultipValue + AddValue)/(9.51413) );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: In terms of best practices, any constant/hardcoded values should be declared outside and referenced here when needed

}
122 changes: 62 additions & 60 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
Date: 2013
*/

#include <stdio.h>
// MDA Tutorial version = AddedLine

#include <stdio.h>
#include <string.h>
#include <time.h>
#include <time.h>
#include <sys/time.h>
#include "NeuralNetwork.h"
#include "utils.h"
Expand All @@ -16,71 +18,71 @@
int main(int argc, char *argv[]) {

char buff[50];
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
strftime (buff, 80, "logs/DNN-%Y-%m-%d-%H-%M-%S.log", timeinfo);
if (LOGGING)
if (LOGGING)
file = fopen (buff, "w");

numNeurons = 0;

NeuralNetwork* net = NULL;

printf("> ---------------------\n"
"> 1) Train OR gate behaviour\n"
"> 2) Train AND gate behaviour\n"
"> 3) Train XOR gate behaviour\n"
"> 4) Train MNIST\n"
"> 5) Empty\n"
"> 6) Exit\n"
"> 7) Load settings and create neural network\n"
printf("> ---------------------\n"
"> 1) Train OR gate behaviour\n"
"> 2) Train AND gate behaviour\n"
"> 3) Train XOR gate behaviour\n"
"> 4) Train MNIST\n"
"> 5) Empty\n"
"> 6) Exit\n"
"> 7) Load settings and create neural network\n"
"> 8) Load new settings from config file\n"
"> 9) Reset/Remake neural network\n"
"> Press '0' to display menu\n"
"> ---------------------\n"
"> 9) Reset/Remake neural network\n"
"> Press '0' to display menu\n"
"> ---------------------\n"
">Please enter your selection: ");

int input = 0;
scanf("%d", &input);
while (input != 6) {
switch (input) {
scanf("%d", &input);
while (input != 6) {
switch (input) {
case 1:
if (net == NULL) {
printf ("You do not have an active Neural Network running.\n");
}
else {
else {
net->trainOR();
}
break;
case 2:
}
break;
case 2:
if (net == NULL) {
printf ("You do not have an active Neural Network running.\n");
}
else {
else {
net->trainAND();
}
}
break;
case 3:
if (net == NULL) {
printf ("You do not have an active Neural Network running.\n");
}
else {
else {
net->trainXOR();
}
break;
break;
case 4:
if (net == NULL) {
printf ("You do not have an active Neural Network running.\n");
}
else {
else {
net->trainMNIST(200, 50);
}
break;
case 5:

break;
}
break;
case 5:
break;
case 7:
read_config("settings.config");
printf ("Settings successfully loaded.\n");
Expand All @@ -92,11 +94,11 @@ int main(int argc, char *argv[]) {
}
printf ("Starting new Neural Network:\n");
net = new NeuralNetwork("reservoir_settings.config");
printf ("New Neural Network successfully created.\n");
break;
case 8:
printf ("New Neural Network successfully created.\n");
break;
case 8:
read_config("settings.config");
printf ("Settings successfully loaded.\n");
printf ("Settings successfully loaded.\n");
break;
case 9:
if (net != NULL) {
Expand All @@ -108,28 +110,28 @@ int main(int argc, char *argv[]) {
printf ("Starting new Neural Network:\n");
net = new NeuralNetwork();
printf ("New Neural Network successfully created.\n");
break;
case 0:
printf("> ---------------------\n"
"> 1) Train OR gate behaviour\n"
"> 2) Train AND gate behaviour\n"
"> 3) Train XOR gate behaviour\n"
"> 4) Train MNIST\n"
"> 5) Empty\n"
"> 6) Exit\n"
"> 7) Load settings and create neural network\n"
break;
case 0:
printf("> ---------------------\n"
"> 1) Train OR gate behaviour\n"
"> 2) Train AND gate behaviour\n"
"> 3) Train XOR gate behaviour\n"
"> 4) Train MNIST\n"
"> 5) Empty\n"
"> 6) Exit\n"
"> 7) Load settings and create neural network\n"
"> 8) Load new settings from config file\n"
"> 9) Reset/Remake neural network\n"
"> Press '0' to display menu\n"
"> ---------------------\n"
">Please enter your selection: ");
break;
default:
printf("> Invalid input. Please try again.\n");
break;
}
printf("\n>Please enter your selection: ");
scanf("%d", &input);
"> 9) Reset/Remake neural network\n"
"> Press '0' to display menu\n"
"> ---------------------\n"
">Please enter your selection: ");
break;
default:
printf("> Invalid input. Please try again.\n");
break;
}
printf("\n>Please enter your selection: ");
scanf("%d", &input);
}
printf ("Exiting...\n");
if (net != NULL) {
Expand Down