W2_A2_Ex-8_Too many elements in d[costs]

Thk for feedbacks

Your code has too many elements in d[‘costs’]. It should have 1, but it actually has 20.

I do not even change this d[cost] value … It says it’s the wrong type for d[cost]
What do you mean that there are 20 elements? Do you know what has caused these error and what I have to do or not?

I’m just summarizing what the error message says.

It doesn’t say wrong type - it says wrong length.

I have not looked at the details of that course in a long time. So I do not remember immediately. I’ll look into it.

Yes you are right… but it say also wrong type of this d[cost] no? if you fix the length that will be the next problem… don’t you think?
What are, where I can see these d[cost ]parameters?

It sound strange that you do not know the answer…
Anyways God knows right?

Here is the answer to your problem. Check it out.

Please read the exception trace more carefully. Notice that the arrow on the left side (indicating which lines are part of the stack trace from the exception) points at the line about the length of the costs array, not the line about the type of the costs array. That means it got past the “type” line without any exceptions and then “threw” on the next assertion about the length.

The thread that Saif pointed you to will give the explanation.

Not strange at all. I am primarily involved with DLS Course 4 and Course 5.

Thks but I did understand with the help of internet; I found on internet the exact line of code without parameters
I would have not given parameters to the learning rate and to the iterations
But all the process should have being explained better in the lectures
Instead of all that mathematical formulas and leaving all the practice to ourselves with this hands on.
How could have I known something like this? And even with your hints I’m doubtful and I would have questions that only with more theory transposed to the real world cases maybe I would dissipate
So generally speaking - this kind of teaching method it’s very complicated and frustrating for me, due to my lack of proficiency in English and in calculus but as I sais also because it’s too much weight on the student shoulders and on yours as mentor
But life socks anyway
Ths

Another simple example of lack of informations

On the programming assignment of W2 " - Overview of the Problem set"
index = 20
plt.imshow(train_set_x_orig[index])
print ("y = " + str(train_set_y[:, index]) + “, it’s a '” + classes[np.squeeze(train_set_y[:, index])].decode(“utf-8”) + “’ picture.”)
Why do you claim the train_set_x_origin through the plt.imshow property and print the train _set_y instead?
The squeeze attributes of numpy what exactly do in this particular case?
Where can I find these kind of info if you do not give it through theory lectures?
And there are dozens of these missing infos
It’s supposed to be on our request ?

If you mean that you specified values for the parameters on the call to optimize, that is simply a misunderstanding of how “named” or “keyword” parameters work in python. This is not a beginning python course: you already need to be a reasonably proficient python programmer to succeed here.

I’m sorry that you are finding it frustrating, but there is no ambiguity about the fact that the course is taught in English, so that should not be a surprise. And knowledge of calculus is not required. They simply give you the math formulas and you have to translate them into python. The mistake in question here is purely a python programming problem, not anything to do with the course material or calculus.

That is just part of the template code they give you. You do not need to modify or even understand that code in order to complete the assignment. Of course it’s a great idea to expand your knowledge by understanding more than is strictly required.

If you think that every single thing should be explained in detail, then I think you are taking the wrong approach here. Try googling “numpy squeeze”. You’ll find that what it does is remove “trivial” dimensions from a numpy object. So, for example, if you have a vector of dimensions 4 x 1, then “squeezing” it will give you a one dimensional vector with 4 elements.

In general they don’t necessarily explain every single numpy function that they use, although they frequently introduce things simply by showing example code. You should not assume that just reading that code will tell you everything you need to know. If you see something that is new or has not been explained yet, try reading the documentation as I just showed how to do.

Hello @Luca_De_Renzo

All your concern is due to lack of programming knowledge. If you are not familiar with Python, you should take some course of it before any Machine Learning course. This Deep learning course assume that you are familiar with Python.

My question was exactly what does the squeeze here… I read the numpy documentation and I understood more or less the meaning but in this particular case I do not understand exactly and if I would have to apply by myself I wouldn’t be able to do so.
I even know that these parts are giving to, but would not have required so much effort to add a single line of “what it does that particular property” do not You think?

You said that the solution to the problem I had with ’ Too many elements in d[costs]
is not due to the fact that I assigned values to the parameters, or precisely it’s has been a misunderstanding of how keyword works in python… even if I knew how to use keywords correctly do you think I would have understood which was the solution to the problem?

I knew that the course would have been taught in English and I took the risk of it
same with Python (I took a basic course but seems to no avail as you said)
but as I already pointed out I would have expected a lesser demonstration of calculus proficiency superiority (also because at the beginning it has been said that would not have been required) and more real world end-to-end applications (that as I said has been completely left on the student and mentor shoulder)

Many thks for the patience
best regards

My question was exactly this one other than the squeeze attribute meaning

index = 20
plt.imshow(train_set_x_orig[index])
print ("y = " + str(train_set_y[:, index]) + “, it’s a '” + classes[np.squeeze(train_set_y[:, index])].decode(“utf-8”) + “’ picture.”)
Why do you claim the train_set_x_origin through the plt.imshow property and print the train _set_y instead?

How can the train _set_y that is been sent to the output can recognize already if it’a cat or not?

You have to read the code. Note what it is doing with train_set_y: it is using it to index into the array called classes. Well, what is in that array? You can add logic to print it out.

So it uses the x values to show the image and the y values to show the labels, right?

On the question about keyword parameters, so what you are saying is that you know the syntax. But in programming, that is not enough: you also have to understand what the syntax actually means so that you can use it correctly to achieve your intended goals.

Sorry if it seems like I am belaboring the point here. Maybe it is just a language problem, but I feel that you keep trying to say that it is our fault that you are not (yet) a good python programmer. We are all here to learn, so let’s keep going with the learning.

Maybe I misunderstood but I thought the ML was not about to become a very good programmer… it’s a change in the paradigm; from programming a PC to give examples to it and this will become able to “program itself” right? We are not still there but near to it, right?
What I would have expected was learning how to pass this infos in a structured models to the PC; obviously with the PC language, but to do so I must understand what am I saying to it — and if you’re telling me that only programmers can do this job do not write at the beginning of this course that is sufficient a basic knowledge of python and calculus.
Or maybe I misunderstand which were the required skills?

Thks make sense… but how the system can recognize if it’s a cat at this step?

This is the training set, so all the samples must include the correct labels. This was explained in some detail in the lectures.