1.Problem Description
In assignment 4, you are required to implement a multiclass classifier with thread. You should train a model to classify handwritten digits from MNIST dataset. And the most important part is that you have to accelerate the matrix multiplication (let it parallelly) by thread.
In training, you should decide how many iterations you train your classifier on your own.
For each iteration, you update your classifier with


Xtraining data matrix (60000 * 784)
Wweight matrix (784 * 10)
(If you consider adding bias to your classifier, you can let W to be 785*10, and add a column with 1s to X.)
y_hatpredicted label (60000 * 10)
ytrue label, you need to transform each label to one-hot. (60000 * 10)
(if label = 2 => [0, 0, 1, 0, 0, 0, 0, 0, 0, 0])
lrlearning rate (scalar)
You need to create threads to accelerate the matrix multiplication in (1). We will tell you how many threads you should create, and each thread should calculate [60000 / thread_num] rows multiplication.
(For example, if thread_num = 1000, each thread should be responsible for 60 rows ([60*784] * [784*10]) multiplication in (1).)
To evaluate the accuracy, you may choose the label with largest probability from 10 classes for each image.
- Format of Inputs & Outputs
InputMNIST dataset (including 4 files)
X_train60000 images, 784 pixels for each image, value0~255
y_train60000 labels, value0~9
X_test10000 images
y_test10000 labels
data link : https://drive.google.com/drive/folders/1wips8uJtKFIlnXVzu2fDC_SRjbxaxiD2?usp=sharing
Outputresult.csv
format


3.Sample Execution
./hw4 [X_train] [y_train] [X_test] [number of threads]
(compilegcc hw4.c -lm -lpthread -O3 -o hw4)

![[Solved] SP-Assignment 4- a multiclass classifier with thread](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] SP-Assignment 1- A simplified Banking System](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.