Saturday, September 24, 2022

AI/ML what is np.linspace

linspace(start, stop, num) returns an array of num evenly spaced numbers in the interval [start, stop]. Set the optional parameter endpoint to False to exclude stop, and set the interval to [start, stop). Set retstep to True optionally to get the step size. Generate evenly spaced arrays using np

linspace is similar to the colon operator, “ : ”, but gives direct control over the number of points and always includes the endpoints. “ lin ” in the name “ linspace ” refers to generating linearly spaced values as opposed to the sibling function logspace , which generates logarithmically spaced values.

linspace allow you to define the number of steps. linspace(0,1,20) : 20 evenly spaced numbers from 0 to 1 (inclusive). arange(0, 10, 2) : however many numbers are needed to go from 0 to 10 (exclusive) in steps of 2. The big difference is that one uses a step value, the other a count

references:

https://www.google.com/search?q=np.linspace&oq=np.linspace&aqs=chrome.0.69i59j0i512l9.400j0j4&sourceid=chrome&ie=UTF-8


No comments:

Post a Comment