Halloween Sale: Flat 70% + Addl. 25% Off + 30 Days Extra Lab on all Courses | Use Coupon HS25 in Checkout | Offer Expires In

  Enroll Now

Cat vs Non-cat Classifier - Reshaping the data

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

INSTRUCTIONS
  • 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 >>)
    

No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...