Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/voidwalker7/perceptron-refactored

The basic perceptroned refactored with a better interface, error handling, and logic.
https://github.com/voidwalker7/perceptron-refactored

c-programming-language neural-network perceptron

Last synced: about 10 hours ago
JSON representation

The basic perceptroned refactored with a better interface, error handling, and logic.

Awesome Lists containing this project

README

        

# Perceptron-Refactored

We are coding the previous perceptron we coded and are making it better.

I will be directly pasting the code below and then after that will be explaining the functions used and concepts used in the code.

```C
#include
#include

#define THRESHOLD 1.6
#define INPUT_COUNT 5

int set_input(int i, char input_buff, float *input){

if(input_buff == 'Y' || input_buff == 'y'){
*input = 1;
}
else if(input_buff == 'N' || input_buff == 'n'){
*input = 0;
if(i==3){
printf("\n \t Well, get ready to lose your sleep!\n");
}
}
else{
return -1;
}
return 0;
}

void *get_questions(int i, float *weight){ //* represents string literal function
switch(i){
case 0:
*weight = 0.8;
return "Do you love to create new things?";
break;
case 1:
*weight = 0.6;
return "Do you love to learn new things continuously?";
break;
case 2:
*weight = 0.4;
return "Are you willing to give up your social life?";
break;
case 3:
*weight = 0.4;
return "Do you have insomnia?";
break;
case 4:
*weight = 0.7;
return "Are you patient enough to search for bugs for hours?";
break;
default:
return "ERROR";
break;
}

}

int main()
{
printf("----------Should you choose computer science as your major?---------\n");

float x[INPUT_COUNT];
float w[INPUT_COUNT];

float p;
float p_max;
char input;

for(int i = 0; i GREEN
"\033[1;31m text \033[0m" //1;31 -> RED
```

Now, to compile the code you just run:
```bash
gcc percep-refac.c
```
and to run the code after that, you run:
```bash
./a.out
```