Week 1: Regularization

ndarray.shape : The dimensions of the array. This is a tuple of integers indicating the size of the array in each dimension. For a matrix with n rows and m columns, “shape” will be “(n,m)”. The length of the “shape” tuple is therefore the number of axes, ndim.
If we will take random dimensions of the array and say we having keep_prob =0.8.
How are we comparing each other with less than sign?
how we can convert entries through this?
Please avoid hyperlinks try to explain here in discourse itself if possible.
Thank you

Hi @starboy,

This is a Numpy operation which basically does the equivalent of python list comprehensions over the numpy array with the less-than operator (<), ie. [x < keep_prob for x in array] but obviously optimized bu numpy.
This op returns a numpy array of the same shape but with booleans, True for those that are >= keep_prob and False otherwise.

You can see this in a Python interpreter:

>>> import numpy as np
>>> D = np.random.rand(3, 2)
>>> D
array([[0.74688471, 0.28276562],
       [0.56159792, 0.4408786 ],
       [0.25525032, 0.79563517]])
>>> D < 0.8
array([[ True,  True],
       [ True,  True],
       [ True,  True]])

Edit: Turns out the second array’s elements, weren’t that great for my example. Here’s another:

>>> D = np.random.rand(3, 2)
>>> D
array([[0.24233397, 0.21245823],
       [0.4839831 , 0.5911745 ],
       [0.41158361, 0.04939783]])
>>> D < 0.4
array([[ True,  True],
       [False, False],
       [False,  True]])

Hope that helps!