Skip to content

Commit c9e2d0a

Browse files
author
Merouane Atig
committed
Update ex7 to fix errors
1 parent b6e50f6 commit c9e2d0a

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

mlclass-ex7/bird_small.mat

44.5 KB
Binary file not shown.

mlclass-ex7/ex7.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@
107107

108108
% Load an image of a bird
109109
A = double(imread('bird_small.png'));
110+
111+
% If imread does not work for you, you can try instead
112+
% load ('bird_small.mat');
113+
110114
A = A / 255; % Divide by 255 so that all values are in the range 0 - 1
111115

112116
% Size of the image

mlclass-ex7/ex7_pca.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@
190190
% Re-load the image from the previous exercise and run K-Means on it
191191
% For this to work, you need to complete the K-Means assignment first
192192
A = double(imread('bird_small.png'));
193+
194+
% If imread does not work for you, you can try instead
195+
% load ('bird_small.mat');
196+
193197
A = A / 255;
194198
img_size = size(A);
195199
X = reshape(A, img_size(1) * img_size(2), 3);

mlclass-ex7/submit.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function submit(partId)
9393
X = reshape(sin(1:165), 15, 11);
9494
Z = reshape(cos(1:121), 11, 11);
9595
C = Z(1:5, :);
96-
idx = 1 + mod(1:15, 3);
96+
idx = (1 + mod(1:15, 3))';
9797
if partId == 1
9898
idx = findClosestCentroids(X, C);
9999
out = sprintf('%0.5f ', idx(:));

mlclass-ex7/submitWeb.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function submitWeb(partId)
8585
X = reshape(sin(1:165), 15, 11);
8686
Z = reshape(cos(1:121), 11, 11);
8787
C = Z(1:5, :);
88-
idx = 1 + mod(1:15, 3);
88+
idx = (1 + mod(1:15, 3))';
8989
if partId == 1
9090
idx = findClosestCentroids(X, C);
9191
out = sprintf('%0.5f ', idx(:));

0 commit comments

Comments
 (0)