Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions Project2-Character-Recognition/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,30 @@ CUDA Character Recognition

**University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 2**

* (TODO) YOUR NAME HERE
* (TODO) [LinkedIn](), [personal website](), [twitter](), etc.
* Tested on: (TODO) Windows 22, i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (Moore 2222 Lab)
* #### Author information

- Tianming Xu (Mark)
- www.linkedin.com/in/tianming-xu-8bb81816a (LinkedIn)
- Tested on: Windows 10, i7-8700 @ 3.20GHz 16GB, GTX 2080 8192MB (my personal desktop)

### (TODO: Your README)
### Output Screenshots(50 Epochs and 30 neuron)

Include analysis, etc. (Remember, this is public, so don't put
anything here that you don't want to share with the world.)
![](img/output.PNG)

The cost drops from 6 to around

#### Features

I implemented a file loader to load in all the training data from the data-set folder and input that to the neural network class. In the class, according to how many epochs we will train, I will loop through all the training data I have in the back propagation algorithm, applying back the delta of weights and bias. The cost of out data set drops significantly after 5 epochs.



#### Performance Analysis

Due to time constraint, I don't have time to do a full performance analysis. However, the GPU can help me handle many matrix operations so, it should be more efficient than the CPU version.



#### Acknowledgement

This homework I especially want to thank Jiangping Xu for helping me figure out the concept of neural network. Also, http://neuralnetworksanddeeplearning.com/ is a fantastic website which describes the concept of neural network concisely. There are python codes for a hand written number recognition program, which helps me a lot for implementing my character recognition program.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ set(SOURCE_FILES

cuda_add_library(character_recognition
${SOURCE_FILES}
OPTIONS -arch=sm_20
OPTIONS -arch=sm_75
)
13 changes: 12 additions & 1 deletion Project2-Character-Recognition/character_recognition/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
#include <cuda_runtime.h>

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <chrono>
#include <stdexcept>

#define FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#define checkCUDAError(msg) checkCUDAErrorFn(msg, FILENAME, __LINE__)

#define BLOCK_SIZE 512
/**
* Check for CUDA errors; print and exit if there was a problem.
*/
Expand All @@ -30,6 +33,13 @@ inline int ilog2ceil(int x) {
return x == 1 ? 0 : ilog2(x - 1) + 1;
}

//isInput = 1 -> input, isInput = 0 -> hidden
//n is number of element in input
inline int matrix_index(int n, int row, int col)
{
return row * n + col;
}


namespace Common {
/**
Expand All @@ -38,6 +48,7 @@ namespace Common {
*
* Adapted from WindyDarian(https://github.com/WindyDarian)
*/

class PerformanceTimer
{
public:
Expand Down
Loading