编程语言
首页 > 编程语言> > 深度学习的优化算法 (Optimization algorithms)

深度学习的优化算法 (Optimization algorithms)

作者:互联网

Python 数组的冒号作用

It’s pretty simple really:

a[start:stop]  # items start through stop-1
a[start:]      # items start through the rest of the array
a[:stop]       # items from the beginning through stop-1
a[:]           # a copy of the whole array

也就是说:

a[1:5] is equivalent to "from 1 to 5" (5 not included)
a[1:] is equivalent to "1 to end"
a[len(a):] is equivalent to "from length of a to end"

There is also the step value, which can be used with any of the above:

a[start:stop:step] # start through not past stop, by step

The key point to remember is that the :stop value represents the first value that is not in the selected slice. So, the difference between stop and start is the number of elements selected (if step is 1, the default).

参考链接:
https://stackoverflow.com/questions/509211/understanding-slice-notation
https://stackoverflow.com/questions/4012340/colon-in-python-list-index

标签:items,equivalent,stop,step,start,算法,Optimization,algorithms,through
来源: https://blog.csdn.net/qq_37454669/article/details/118712407