Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Course1 - Week 2 - PA 2 - Logistic Regression with a Neural Network mindset #23

Open
nucleosome opened this issue Dec 28, 2021 · 2 comments

Comments

@nucleosome
Copy link

In part 2 where we try to reshape the training and test examples, i.e. to flatten matrix "train_set_x_orig" and "test_set_x_orig".

In this note, the author uses "train_set_x_flatten = train_set_x_orig.reshape(train_set_x_orig.shape[1]*train_set_x_orig.shape[2]*train_set_x_orig.shape[3],train_set_x_orig.shape[0])", which fails in making every colum as a training example and a wrong result of train accuracy and test accuracy.

I think "train_set_x_flatten = train_set_x_orig.reshape(train_set_x_orig.shape[0], -1).T" would be better.

please feel free to discuss this:)

@BJBijvoet
Copy link

BJBijvoet commented Dec 29, 2021

You are correct, the training and testing examples should be reshaped as:

train_set_x_flatten = train_set_x_orig.reshape(train_set_x_orig.shape[0], -1).T
test_set_x_flatten = test_set_x_orig.reshape(test_set_x_orig.shape[0], -1).T

@woo1127
Copy link

woo1127 commented Oct 27, 2022

A more shorter answer is

train_set_x_flatten = train_set_x_orig.reshape(-1, train_set_x_orig.shape[0])
test_set_x_flatten = test_set_x_orig.reshape(-1, test_set_x_orig.shape[0])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants