mnist-neural-network-plain-c

A neural network implementation for the MNIST dataset, written in plain C

  • Owner: AndrewCarterUK/mnist-neural-network-plain-c
  • Platform:
  • License::
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

MNIST Neural Network in C

This source code seeks to replicate the MNIST For ML Beginners tutorial from the Tensorflow website using plain C code.

The task is to recognise digits, such as the ones below, as accurately as possible.

MNIST digits

By AndrewCarterUK (Twitter)

Contents

  • mnist.c: Glue code that runs the algorithm steps and reports algorithm accuracy
  • mnist_file.c: Retrieves images and labels from the MNIST dataset
  • neural_network.c: Implements training and prediction routines for a simple neural network

Usage

make
./mnist

Description

The neural network implemented has one output layer and no hidden layers. Softmax activation is used, and this ensures that the output activations form a probability vector corresponding to each label. The cross entropy is used as a loss function.

The algorithm reaches an accuracy of around 92% over 1000 steps.

Expected Output

Step 0000	Average Loss: 4.36	Accuracy: 0.152
Step 0001	Average Loss: 3.42	Accuracy: 0.188
Step 0002	Average Loss: 2.97	Accuracy: 0.298
Step 0003	Average Loss: 2.53	Accuracy: 0.319
Step 0004	Average Loss: 2.19	Accuracy: 0.412
Step 0005	Average Loss: 2.08	Accuracy: 0.437
Step 0006	Average Loss: 1.73	Accuracy: 0.468
Step 0007	Average Loss: 1.51	Accuracy: 0.447
Step 0008	Average Loss: 1.57	Accuracy: 0.496
Step 0009	Average Loss: 1.45	Accuracy: 0.516
Step 0010	Average Loss: 1.78	Accuracy: 0.559
...

training evolution

Main metrics

Overview
Name With OwnerAndrewCarterUK/mnist-neural-network-plain-c
Primary LanguageC
Program languageMakefile (Language Count: 2)
Platform
License:
所有者活动
Created At2018-04-08 11:37:54
Pushed At2021-03-15 22:55:35
Last Commit At2021-03-15 22:55:35
Release Count0
用户参与
Stargazers Count98
Watchers Count6
Fork Count25
Commits Count16
Has Issues Enabled
Issues Count5
Issue Open Count2
Pull Requests Count1
Pull Requests Open Count0
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private