Login using Social Account
     Continue with GoogleLogin using your credentials
We need to reshape the data in a way compatible to be fed to our Machine Learning Algorithm - Logistic Regression Classifier.
Now, let us reshape the images to a flat vector of shape (height x width x 3, 1).
This could be done by using reshape(train_set_x_orig.shape[0],-1)
.
-1
in reshape function is used when you don't want to explicitly tell the dimension of that axis.
E.g, here, we want each of the 209 samples in the train set to be represented as a single vector of shape (height x width x 3).
By writing train_set_x_orig.reshape(train_set_x_orig.shape[0], -1)
, the array will get reshaped in such a way that the resulting array has 209 rows and this is only possible by having (height x width x 3) columns, hence, (height x width x 3,209).
We then transpose the matrix by using train_set_x_orig.reshape(train_set_x_orig.shape[0], -1).T
Reshape the train_set_x_orig
, validation_x
, and test_set_x
, and transpose those vectors.
train_set_x_flatten = train_set_x_orig.reshape(train_set_x_orig.shape[0], -1).T
validation_x_flatten = << your code comes here >>
test_set_x_flatten = << your code comes here >>
Print the shapes of the labels and flattened transposed vectors obtained above, for train, validation, and test set.
print ("train_set_x_flatten shape: ", train_set_x_flatten.shape)
print ("train_set_y shape: ", train_set_y_orig.shape)
print ("validation_x_flatten shape: ", << your code comes here >>)
print ("validation_y shape: ", << your code comes here >>)
print ("test_set_x_flatten shape: ", << your code comes here >>)
print ("test_set_y shape: ", << your code comes here >>)
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...