Hello – I’m working on exercise 8, and am getting an error - TypeError: ‘tuple’ object cannot be interpreted as an integer. Would appreciate insight on why this is breaking. Thank you!
Apparently, you have a wrong value for num_px
, which needs to be 64. This is what you set at Exercise 1. Please double check.
If we look at the shape for your num_px
, it is exactly same as the shape of train_set_x_orig
.
So, please check your result of Exercise 1, and also any incorrect updates for num_px
after that in your notebook.
it looks like you’re using a tuple as the parameter for shape.
Instead, use it like
plt.imshow(test_set_x[:, index].reshape(numpx, num_num_px, 3))
I’m not taking this course, so it’s my gut feel looking into the stacktrace.
Good try, but, I suppose your code gets the same error.
There are some errors in your both approach and implementation.
Approach:
it looks like you’re using a tuple as the parameter for shape.
This is a good starting point. But, you need to dig one step why it became a tuple.
There are good clues in Tricia’s trace (print).
- The shape of num_px is (209,64,64,3). Even only looking at a trace, you should be aware, from the last 3 dimensions, that this is most likely a set of color images.
- And, this code picks up 1 sample (index=1) from “test_set_x”, which should be (12288,1) from a trace.
- Then, look at the 3rd parameter for reshape(). It’s 3. So,
num_px
*num_px
must be 4096 and the value ofnum_px
should be 64. Then, we understand that this code is trying to reshape one slice of a test set to (64,64,3), which exactly matches to our first guess from givennum_px
, i.e, a color image.
This is the logical flow for debugging. num_px
needs to be 64. Then, we can start to think why num_px
became to 64.
Implementation:
For reshape, you set numpx
and num_num_px
. How you get numpx
and num_num_px
?
You may want to show both are scalar value obtained from somewhere, not num_px
. Even in that case, from an original code, both needs to be the same value. So, selecting one variable is the right way to guide.
If this is just a typo, the shape of num_px
is still (209,64,64,3). Even you remove one pair of parenthesis, reshape((209,64,64,3), (209,64,64,3), 3) does not work.
In net, you have a good idea to start. What you need is to dig one step further to see “the truth”.
Thank you so much! I really appreciate your help.