代写Group Course Project 2025代写Web开发

Group Course Project 2025

Deadline: 23:59, June 5th   2025


Attention:  Students can try to understand the project requirements first, and then work out a workflow of the program, including the main functions, sub-functions. The project needs knowledge from the of reading file which can be found in your textbook and lecture notes.

Requirements

1.   In this project, please use A, B, C,  , Sas the matrix names in the program.

A well-structured program should include some sub-functions for special purpose, for example: Reshape, Multiply, Add, Activate and SoftMax. (If your program has only one main function, you might  lose some marks for non-functional requirements, but this will not affect marks for functional requirements.)

2.   If a user inputs one image file name (e.g., p1.pgm), then output the file name and the digit after the recognition (e.g., p1.pgm: 9)

3.   If a user inputs more than one image  file names (e.g., p1.pgm, p2.pgm), the program should output each file name and its corresponding digit in the list (e.g., p1.pgm: 5, p2.pgm: 2).

4.   After output is given, there should be a prompt, asking the user if he wants to continue. If he chooses to continue, input Y, otherwise, input N. If the user chooses Y, ask the user to input image file name to repeat the previous work.

Sample I/O: 

5.   Take the screenshot of the results of each number recognition, and put them in a pdf file, in the same the pdf file should also include the names of the group members, each group only need to submit ONE project!


6.   Use Git and Gitee to collaborate on the project with your team members (<=5). Create a new repository for this project; each member should fork the repository, work on their own branch, and use a pull request to merge changes into the master branch. The upstream master branch should  only contain merge commits (i.e., you are not allowed to push code directly to  the upstream master branch; direct pushes will result in point deductions).

7.   When creating a pull request, describe its purpose and include your name in the description. The pull request must be reviewed by at least one other team member before being merged into the upstream master branch.

8.   Any commits to the upstream master branch after the deadline will not be accepted.  When submitting your program, include the gitee repository link and the PDF file (no need to submit any .c or .h file, I will read your code from gitee). Programs with compilation errors will receive no score.

9.   You may use the code template:   https://gitee.com/zhang-jiaqi33/c-programming-spring- 2025/tree/master/final-project-template

Project Detail

In this project, students will use the trained data to write a program to recognize an image with handwriting digit, for example,

The data are trained by a neural network, which is a computational model inspired by how biological neural networks function in the human brain. Neural networks consist of layers of interconnected nodes, often referred to as neurons. In the context of machine learning, neural networks are used for tasks such as pattern recognition, classification, regression, and more. A reference is provided in case you are interested in this topic.

For the model, we have built 1 Input Layer, 2 Hidden Layers, and 1 Output Layer:


.    Input  Layer:  Utilizes Flatten to convert the 2D array of 28x28 pixels into a 1D array of 784 pixels.  It’s necessary to flatten the input before passing it to the dense layers.

.    Hidden Layers: Each of these layers contains 128 neurons and utilizes the ReLU activation function.

.     Output Layer: This layer consists of 10 neurons, each representing a digit from 0 to 9, and utilizes the Softmax activation function to obtain the probability for each digit.

We have already trained the data and obtained the weights and biases stored in .txt files, for more information about the weights and biases, please refer to the reference provided. W1.txt and W2.txt correspond to the weights of the first and the second hidden layers, respectively. B1.txt and B2.txt are the biases. By using these data, you can write a program that can recognize a single handwritten digit number.

The image is stored in a file. To recognize the image, the image information in the file must be read and  stored in a two-dimensional array  (matrix), and a certain algorithm is used to calculate the similarity of the handwriting digit to 10 digits from 0 to 9. The digit with highest similarity will be the output. For example,

Figure 1 From Image to array, then from array to digit

You may need to follow the following steps to write a program for the recognition of digit numbers. Or you can write your own code to do this. You will get full credits if your program can recognize the digit numbers correctly.

Phase 1: prepare necessary functions

(1) Write a function to read a pgm file and store in a 28-by-28 matrix:

- Input: A file that stores an image with 28×28 pixels. Each pixel can be represented as an integer between 0 and 255 (inclusive).

- Output: Matrix A (28×28).



- Declare an array floatA[28][28], use the fgets, which is learned in Chapter 12,  function to skip the first four lines in the file, which are some basic information about this image.

- Use fgetc function repeatedly to read each pixel from the fifth line until 784 chars have been obtained. Store these chars in the 28-by-28 matrix.

- Normalize each pixel value by dividing 255.0 and store into array (Matrix A).

char pixel=fgetc(fp);

pixel=(double)pixel / 255.0;

You may declare the function as

void pgm_to_matrix(const char *file_path, const int n_rows, const int n_cols,

double A[n_rows][n_cols]);

Example: if you read the file example/example0.pgm, the you matrix should be the same as the following if only 2 digits are printed.


(2) Write a function to reshape a m-by-n matrix to a 1-by-(m*n) matrix. For example, if the 2-by-2 matrix is [1 2; 3 4], then the output should be a 1-by-4 matrix [1 2 3 4]. You may declear the function as

void matrix_to_vector(const int n_rows, const n_cols, const double matrix[n_rows][n_cols],

double vector[1][n_rows * n_cols]);

(3) Write a function to convert a 1-by-m*n matrix to a m-by-n matrix, which is the reverse procedure of (2). For example, if the the input is a 1-by-4 matrix [1 2 3 4], then the output is a 2-by-2 matrix is [1 2; 3 4], then the output should be.

You may declare the function as


void vector_to_matrix(const int n_rows, const n_cols,

const double vector[1][n_rows * n_cols],

double matrix[n_rows][n_cols]);

(4) Write a function to read data in a txt file and store in a 1-by-n matrix, where n is the number of elements in the txt file. You may create a simple txt file to verify that your function is correct. You may declare the function as

void read_txt_data(const char *filename, const int n, double array[1][n]);

(5) Write a function to add two matrices, please refer to Linear Algebra we learned last semester on how to add two matrices. You may declare the function as

void add_matrices(const int n_rows, const int n_cols, const double mat1[n_rows][n_cols],

const double mat2[n_rows][n_cols], double result[n_rows][n_cols]);

(6) Write a function to multiply two matrices, please refer to Linear Algebra we learned last semester on how to do matrix-matrix multiplication. You may declare the function as

void matrix_mul(const int n_rows, const int n_cols, const int p, const double matrix1[n_rows][p],

const double matrix2[p][n_cols], double matrix_product[n_rows][n_cols]);

(7) Activate function. Write a function to get the maximum of the m-th element of the vector F and 0, then store in G:

Activate: G[m] = max(F[m], 0), m=0, 1,..., SIZE.

You may declare the function:

void active_function(const int SIZE, const double F[1][SIZE],

double G[1][SIZE])

(8) SoftMax. The soft max of a vector is given by



where max(L) is the maximum value in Matrix L. For example, if L=[-1, 0.2, 4, -19, 10], then max(L) is 10. If you want to use max function in C, you may need to put #include <math.h> at the beginning of the program. You may define the function as

void soft_max(const int n_rows, const int n_cols,

const double L[n_rows][n_cols], double S[n_rows][n_cols]);






热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图