Skip to content

blacklin/miniMNIST-c

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

miniMNIST-c

This project implements a mini neural network in C for classifying handwritten digits from the MNIST dataset.

Features

  • Two-layer neural network (input -> hidden -> output)
  • ReLU activation for hidden layer
  • Softmax activation for output layer
  • Cross-entropy loss function
  • Stochastic Gradient Descent (SGD) with momentum
  • L2 regularization

Prerequisites

  • GCC compiler
  • MNIST dataset files:
    • train-images.idx3-ubyte
    • train-labels.idx1-ubyte

Compilation

gcc -o nn nn.c -lm

Usage

  1. Place the MNIST dataset files in the data/ directory.
  2. Compile the program.
  3. Run the executable:
./nn

The program will train the neural network on the MNIST dataset and output the accuracy and average loss for each epoch.

Configuration

You can adjust the following parameters in nn.c:

  • HIDDEN_SIZE: Number of neurons in the hidden layer
  • LEARNING_RATE: Initial learning rate
  • MOMENTUM: Momentum coefficient for SGD
  • L2_LAMBDA: L2 regularization coefficient
  • EPOCHS: Number of training epochs
  • BATCH_SIZE: Mini-batch size for training

License

This project is open-source and available under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%