Week 4 assignment 2 Exercise 1


Thks for helping

Try using shape instead of get_shape, and adjust the sets of parenthesis.

a_G.shape.as_list()

You were right…
I 've tried so many different codes I was getting crazy
But in the instructions were explicitly written

  • To retrieve dimensions from a tensor X, use: X.get_shape().as_list()

But your code didn’t have the parenthesis after as_list. “as_list” is a method, so it requires parenthesis.

There is more than one way to write the code so it works.

There’s an important “meta” lesson here: “saving time” by not reading the instructions carefully is frequently not a net savings of time. :nerd_face:

Dear, How did you know that my code was without parenthesis? I can assure you it had…
But your comment makes me think that were able to see my notebook even without I had submit it ?
And if it so, why didn’t you tell me before, that it was missing a parenthesis, instead of suggest me to write a_G.shape.as_list()?
Just for fun
Anyway thks for the right hint… I was tripping out

If you look at the error you posted, it shows some part of your code. This is how Tom told you that your code is without parenthesis. One more thing, can you see the arrow (—>) at the start of that line? This arrow tells you where the bug is.

Thks Saif but the parenthesis were at their place and probably it was one of the 100 changes I have made to make it works even unconsciously…
Anyway now seems to work in both ways magically… with the get_shape().as_list() and with a_G.shape.as_list()
Thks to all

It is not working magically but you are using different ways to do the same thing, get_shape() and shape.

Believe me it wasn’t work with the a_G.get_shape().as_list()
Otherwise, Why would your colleague have suggested me the other?
For fun?

You were using a_G.get_shape().as_list, not the a_G.get_shape().as_list() which you claim now. Check your posted error again.

I told the parenthesis were at their right place, maybe not when I made the screenshot, even if I wouldn’t bet on it. I have tried at least 100 code lines yesterday.
But at the end, even if you do not want to believe me; why do you think your colleague would have bothered to suggest me the other code if it was only a problem of parenthesis?

Well, I believe the error you posted.

He already answered that:

There is more than one way to write the code so it works.

But, if you are still unsatisfied, it’s better to ask him.

From the image in your original post:

There are no parenthesis after “as_list”.

The mentors cannot see your notebook, only what you post on the forum.