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: 2 months ago
JSON representation
The basic perceptroned refactored with a better interface, error handling, and logic.
- Host: GitHub
- URL: https://github.com/voidwalker7/perceptron-refactored
- Owner: VoIDWALkER7
- Created: 2024-06-14T19:06:30.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-06-14T19:09:00.000Z (11 months ago)
- Last Synced: 2025-03-13T23:44:20.835Z (2 months ago)
- Topics: c-programming-language, neural-network, perceptron
- Language: C
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 5int 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
```