# Help with parameters (Exercise 5 - Week 3)M4ML

I am working on this section in the Week 3 assignment:
2.4 - Integrate parts 2.1, 2.2 and 2.3 in nn_model()

The given code is below, I have added nothing. The ??? is what I need help with.
How do I define the parameters?
Am I supposed to be doing something with the number of iterations?

def nn_model(X, Y, num_iterations=10, print_cost=False):
“”"
Arguments:
X – dataset of shape (n_x, number of examples)
Y – labels of shape (n_y, number of examples)
num_iterations – number of iterations in the loop
print_cost – if True, print the cost every iteration

``````Returns:
parameters -- parameters learnt by the model. They can then be used to make predictions.
"""

n_x = layer_sizes(X, Y)[0]
n_y = layer_sizes(X, Y)[1]

# Initialize parameters
### START CODE HERE ### (~ 1 line of code)
parameters = **????**
### END CODE HERE ###
``````

I am a Python noob and I joined this course for the mathematics, not realizing that it would require more Python than I know (basically nothing!).

Anyway, some help please on how to define/initialize the parameters.

Thank you.

1 Like

You wrote a function for that earlier in this notebook, right? It’s called … wait for it … `initialize_parameters`. You just need to call that with the appropriate parameter values. Take a look at the definition of that function to understand what it needs.

Have you done programming in languages other than python? If so, then you can probably get by spending some time reading a few python tutorials. But if this is literally your first exposure to any kind of programming, you’re in trouble, as you’ve probably figured out. The best idea might be to put this on “pause” and go take an “intro to python” course first.

I appreciate your quick reply. I’ll go back again and try to figure it out.
As stated, I am a total noob, and definitely in trouble.
I took this course for the mathematics, and Coursera said it was a beginner’s course – not for Python!
I’ve scrapped through the first two weeks, but it’s getting more difficult now.
Is there an intro Python course you’d recommend?
I’ve found Kaggle, and but sound advice could save me time and effort.
Thanks again.

3 Likes

There are lots of online courses for python. I haven’t really taken any of them because I already had 30 years of programming experience by the time I ran into python. I learned to program back when FORTRAN was the “language du jour” which tells you something about how long ago it was.

Is this literally your first time doing any kind of programming? I’ve heard people say good things about the University of Michigan Python for Everybody Coursera specialization. You probably don’t need to go through all of that. Just looking at the syllabus, Course 1 and Course 2 of that would be enough to get you going here.

The second entry in the search on Coursera is Crash Course on Python from Google. Also worth a look, but have no personal experience taking it.

If you look at the Python.Org website, they’ve got a lot of free online educational material as well. E.g. here’s their Beginner’s Guide.

Yes, this is my first time programming, and your feedback is much appreciated.
I’m a teacher and I took this course for the mathematics refresher, and its application to machine learning. Coursera made it seem like this was a beginner’s class, so I feel a bit misled, and not sure I want to use them again. But as you said, there are many options online – I’ll just have to dive in.

I’ve spent hours trying to figure out that one line of code for the parameters. Sure sign that I’ve got to understand Python better. Can you drop me one more hint before I put it on pause and start my beginner’s journey into Python?

2 Likes

Look at the earlier part of the notebook. They lead you through the creation of a bunch of functions that perform particular parts of the computations that you need. Then you “put it all together” in the top level function `nn_model`. From `nn_model`, you call each of the previous functions that you created at the appropriate point. They tell you what to do in the comments. So when they say in the comment “Initialize parameters”, does that remind you of the name of any of the “subroutines” you built earlier?

If you have some math background, you should already be comfortable with the concept of a “function”, right? In python, it’s just like in math: a “function” is a body of code that takes some inputs and gives you some outputs in a well defined way.

BTW You are reading the instructions carefully, right? Just breezing through or “skimming” them to “save time” generally ends up not being a net savings of time, particularly if you are already struggling a bit.

On the question of not understanding that programming was a prerequisite, here’s the introductory page to their curriculum offerings here. You’ll notice that even under “Introductory” they specifically mention that programming experience is required.

I’m definitely not saving time ; )

I’ll go through it again slowly – I’ve got one more week before it’s due.
That should be more than enough time to figure out where I stand.
Honestly, even if I can figure it out from context, as I did in Week 1 & 2, I will need to take a beginner’s course in Python to be able to function independently in the language.

Thanks again.

Don’t worry about the deadlines. There is no penalty for missing them and they just let you reset them.

In response to this post, I found this course through Coursera, not DeepLearning.AI – and it wasn’t as clear there. Still, the fault is mine.

2 Likes

Ah, good to know. Takes a little of the pressure off.

It’ll take a little work and time to learn python, but it’s not wasted time if you want to be involved in Deep Learning or ML in general. Python is the “lingua franca” these days and also just understanding more directly how programming works will inform your intuitions in a lot of ways as well.