https://github.com/nomadsdev/rnn-model-with-c
model rnn with c
https://github.com/nomadsdev/rnn-model-with-c
ai c model neural-network rnn
Last synced: 4 months ago
JSON representation
model rnn with c
- Host: GitHub
- URL: https://github.com/nomadsdev/rnn-model-with-c
- Owner: nomadsdev
- Created: 2025-04-29T18:43:24.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-04-29T18:46:56.000Z (9 months ago)
- Last Synced: 2025-08-02T06:30:17.616Z (6 months ago)
- Topics: ai, c, model, neural-network, rnn
- Language: C
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ง RNN in C
This is a simple implementation of a **Recurrent Neural Network (RNN)** in **pure C**.
It demonstrates the concept of forward propagation over a sequence of time-series inputs without using any external libraries.
---
## ๐ Project Structure
```
rnn-c/
โโโ include/ # Header files
โ โโโ rnn.h # RNN structure and declarations
โ โโโ utils.h # Utility functions (e.g., matrix multiplication)
โโโ src/ # Source code
โ โโโ rnn.c # RNN logic (init, forward, print)
โ โโโ utils.c # Math utility implementation
โโโ data/ # Example input data (optional)
โ โโโ sample_input.txt
โโโ main.c # Program entry point
โโโ Makefile # Build configuration
โโโ README.md # This file
```
---
## ๐งช Requirements
- GCC or compatible C compiler (e.g. `gcc`, `clang`)
- `make` (for building the project)
---
## โ๏ธ Build Instructions
### 1. Clone or download the project:
```bash
git clone https://github.com/nomadsdev/rnn-model-with-c.git
cd rnn-c
```
### 2. Build the project using `make`:
```bash
make
```
This compiles all `.c` files and generates an executable named `rnn`.
---
## ๐ Running the Program
```bash
./rnn
```
### Expected Output:
```text
Time step 0: Output: 0.4938
Time step 1: Output: 0.4962
Time step 2: Output: 0.4975
```
The program performs forward propagation across 3 time steps using a hardcoded input sequence (`0.1`, `0.5`, `0.9`) and prints the output of the RNN at each step.
---
## ๐งฐ How to Modify Inputs
To change the input sequence:
1. Open `main.c`
2. Modify the `inputs[]` array:
```c
float inputs[] = {0.2f, 0.4f, 0.6f, 0.8f};
```
3. Rebuild the project:
```bash
make clean && make
./rnn
```
---
## ๐ ๏ธ How to Extend This Project
Here are some ideas for improving this base project:
- โ
Add Backpropagation Through Time (BPTT)
- ๐ Loss function and training loop
- ๐ Load input from file (`sample_input.txt`)
- ๐ง Increase model complexity (e.g., stacked RNN layers)
- ๐พ Save and load weights to/from file