没有合适的资源?快使用搜索试试~ 我知道了~
ex3文档1
需积分: 0 0 下载量 70 浏览量
2022-08-03
12:18:25
上传
评论
收藏 287KB PDF 举报
温馨提示
试读
12页
ex3文档1
资源详情
资源评论
资源推荐
Programming Exercise 3:
Multi-class Classification and Neural Networks
Machine Learning
Introduction
In this exercise, you will implement one-vs-all logistic regression and neural
networks to recognize hand-written digits. Before starting the programming
exercise, we strongly recommend watching the video lectures and completing
the review questions for the associated topics.
To get started with the exercise, you will need to download the starter
code and unzip its contents to the directory where you wish to complete the
exercise. If needed, use the cd command in Octave/MATLAB to change to
this directory before starting this exercise.
You can also find instructions for installing Octave/MATLAB in the “En-
vironment Setup Instructions” of the course website.
Files included in this exercise
ex3.m - Octave/MATLAB script that steps you through part 1
ex3 nn.m - Octave/MATLAB script that steps you through part 2
ex3data1.mat - Training set of hand-written digits
ex3weights.mat - Initial weights for the neural network exercise
submit.m - Submission script that sends your solutions to our servers
displayData.m - Function to help visualize the dataset
fmincg.m - Function minimization routine (similar to fminunc)
sigmoid.m - Sigmoid function
[?] lrCostFunction.m - Logistic regression cost function
[?] oneVsAll.m - Train a one-vs-all multi-class classifier
[?] predictOneVsAll.m - Predict using a one-vs-all multi-class classifier
[?] predict.m - Neural network prediction function
? indicates files you will need to complete
1
Throughout the exercise, you will be using the scripts ex3.m and ex3 nn.m.
These scripts set up the dataset for the problems and make calls to functions
that you will write. You do not need to modify these scripts. You are only
required to modify functions in other files, by following the instructions in
this assignment.
Where to get help
The exercises in this course use Octave
1
or MATLAB, a high-level program-
ming language well-suited for numerical computations. If you do not have
Octave or MATLAB installed, please refer to the installation instructions in
the “Environment Setup Instructions” of the course website.
At the Octave/MATLAB command line, typing help followed by a func-
tion name displays documentation for a built-in function. For example, help
plot will bring up help information for plotting. Further documentation for
Octave functions can be found at the Octave documentation pages. MAT-
LAB documentation can be found at the MATLAB documentation pages.
We also strongly encourage using the online Discussions to discuss ex-
ercises with other students. However, do not look at any source code written
by others or share your source code with others.
1 Multi-class Classification
For this exercise, you will use logistic regression and neural networks to
recognize handwritten digits (from 0 to 9). Automated handwritten digit
recognition is widely used today - from recognizing zip codes (postal codes)
on mail envelopes to recognizing amounts written on bank checks. This
exercise will show you how the methods you’ve learned can be used for this
classification task.
In the first part of the exercise, you will extend your previous implemen-
tion of logistic regression and apply it to one-vs-all classification.
1
Octave is a free alternative to MATLAB. For the programming exercises, you are free
to use either Octave or MATLAB.
2
1.1 Dataset
You are given a data set in ex3data1.mat that contains 5000 training exam-
ples of handwritten digits.
2
The .mat format means that that the data has
been saved in a native Octave/MATLAB matrix format, instead of a text
(ASCII) format like a csv-file. These matrices can be read directly into your
program by using the load command. After loading, matrices of the correct
dimensions and values will appear in your program’s memory. The matrix
will already be named, so you do not need to assign names to them.
% Load saved matrices from file
load('ex3data1.mat');
% The matrices X and y will now be in your Octave environment
There are 5000 training examples in ex3data1.mat, where each training
example is a 20 pixel by 20 pixel grayscale image of the digit. Each pixel is
represented by a floating point number indicating the grayscale intensity at
that location. The 20 by 20 grid of pixels is “unrolled” into a 400-dimensional
vector. Each of these training examples becomes a single row in our data
matrix X. This gives us a 5000 by 400 matrix X where every row is a training
example for a handwritten digit image.
X =
— (x
(1)
)
T
—
— (x
(2)
)
T
—
.
.
.
— (x
(m)
)
T
—
The second part of the training set is a 5000-dimensional vector y that
contains labels for the training set. To make things more compatible with
Octave/MATLAB indexing, where there is no zero index, we have mapped
the digit zero to the value ten. Therefore, a “0” digit is labeled as “10”, while
the digits “1” to “9” are labeled as “1” to “9” in their natural order.
1.2 Visualizing the data
You will begin by visualizing a subset of the training set. In Part 1 of ex3.m,
the code randomly selects selects 100 rows from X and passes those rows
to the displayData function. This function maps each row to a 20 pixel by
20 pixel grayscale image and displays the images together. We have provided
2
This is a subset of the MNIST handwritten digit dataset (http://yann.lecun.com/
exdb/mnist/).
3
剩余11页未读,继续阅读
张景淇
- 粉丝: 40
- 资源: 276
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0