Why do we do data creation routines?

Data creation routines means to initialize a numpy array with a specific shape and initial values. Am I correct?
Also, please have a look at the screenshot attached. Why do we have to initialize the numpy arrays in this way? For example: The return will be tuple; it will have 4 values; all values will be zeros; or all values will be random etc etc. Why do we have to do these things?

Which course are you attending?

You posted in “AI Questions”, but probably your message should be in one of the course forums in “Course Q&A”.

You can move your thread using the ‘pencil’ icon in the thread title.

I am studying ML Specialization by Andrew Ng.
So I a have to ask questions in Course Q&A?

It generally works better and is more likely to get noticed by the right people who could answer your question if you put it in the right category.

For this particular question, there are many cases in which we need input data to work with in algorithms. There can be input data that is just given to us and in those cases we need functions that will load it from whatever form it is given to us (typically files) into numpy arrays or TensorFlow tensors or whatever we are using. But there are other cases in which the data is not given to us. The typical case there would be “parameters” of the models we are creating which are weights and bias values that are used in math formulas to modify the inputs and convert them into the answers our model will create. Those parameter values are learned by the algorithms, but we have to start from somewhere. For some types of algorithms, e.g. Logistic Regression, we can initialize them to all zeros of the appropriate size and shape and then the algorithm can learn them. In other cases, e.g Neural Networks, we can’t use zeros and need small random values to start with in order to be able to learn. So we use the various functions provided by numpy to “initialize” or create those data items.

You’ll see lots of examples of this as you go through MLS and DLS.

1 Like