Path: blob/master/section-2-data-science-and-ml-tools/introduction-to-numpy-video.ipynb
874 views
Kernel: Python 3
In [1]:
1. DataTypes & Attributes
In [2]:
Out[2]:
array([1, 2, 3])
In [3]:
Out[3]:
numpy.ndarray
In [4]:
In [5]:
Out[5]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [6]:
Out[6]:
array([[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]])
In [7]:
Out[7]:
(3,)
In [8]:
Out[8]:
(2, 3)
In [9]:
Out[9]:
(2, 3, 3)
In [12]:
Out[12]:
array([1, 2, 3])
In [13]:
Out[13]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [14]:
Out[14]:
array([[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]])
In [10]:
Out[10]:
(1, 2, 3)
In [15]:
Out[15]:
(dtype('int64'), dtype('float64'), dtype('int64'))
In [17]:
Out[17]:
array([[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]])
In [16]:
Out[16]:
(3, 6, 18)
In [18]:
Out[18]:
(numpy.ndarray, numpy.ndarray, numpy.ndarray)
In [19]:
Out[19]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [20]:
Out[20]:
2. Creating arrays
In [21]:
Out[21]:
array([1, 2, 3])
In [23]:
Out[23]:
dtype('int64')
In [24]:
In [25]:
Out[25]:
array([[1., 1., 1.],
[1., 1., 1.]])
In [26]:
Out[26]:
dtype('float64')
In [27]:
Out[27]:
numpy.ndarray
In [28]:
In [29]:
Out[29]:
array([[0., 0., 0.],
[0., 0., 0.]])
In [30]:
Out[30]:
array([0, 2, 4, 6, 8])
In [32]:
Out[32]:
array([[5, 9, 7, 6, 4],
[1, 9, 6, 7, 1],
[7, 5, 5, 9, 0]])
In [33]:
Out[33]:
15
In [34]:
Out[34]:
(3, 5)
In [37]:
Out[37]:
array([[0.22167345, 0.34437229, 0.73864985],
[0.66670981, 0.82113975, 0.92073724],
[0.03024207, 0.36297608, 0.39167642],
[0.22192665, 0.85257304, 0.62190959],
[0.15216592, 0.0638989 , 0.71405768]])
In [38]:
Out[38]:
(5, 3)
In [122]:
Out[122]:
array([[0.72816128, 0.82122761, 0.76051512],
[0.00714328, 0.42025683, 0.46313622],
[0.0554995 , 0.54144213, 0.60777075],
[0.82845319, 0.94180927, 0.12814785],
[0.23043067, 0.6591584 , 0.13247399]])
In [98]:
Out[98]:
array([[0, 3, 1],
[8, 1, 3],
[8, 5, 6],
[0, 6, 0],
[4, 0, 9]])
In [115]:
Out[115]:
array([[0.07630829, 0.77991879, 0.43840923],
[0.72346518, 0.97798951, 0.53849587],
[0.50112046, 0.07205113, 0.26843898],
[0.4998825 , 0.67923 , 0.80373904],
[0.38094113, 0.06593635, 0.2881456 ]])
In [117]:
Out[117]:
array([[0.20484909, 0.49076589, 0.37238469],
[0.47740115, 0.36589039, 0.83791799],
[0.76864751, 0.31399468, 0.57262533],
[0.27604905, 0.45284293, 0.35297837],
[0.65739946, 0.37035108, 0.45909298]])
In [123]:
Out[123]:
array([[0, 3, 1],
[8, 1, 3],
[8, 5, 6],
[0, 6, 0],
[4, 0, 9]])
3. Viewing arrays and matrices
In [124]:
Out[124]:
array([0, 1, 3, 4, 5, 6, 8, 9])
In [125]:
Out[125]:
array([1, 2, 3])
In [126]:
Out[126]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [127]:
Out[127]:
array([[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]])
In [128]:
Out[128]:
1
In [130]:
Out[130]:
(2, 3)
In [129]:
Out[129]:
array([1. , 2. , 3.3])
In [131]:
Out[131]:
(2, 3, 3)
In [132]:
Out[132]:
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
In [133]:
Out[133]:
array([[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]])
In [134]:
Out[134]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [135]:
Out[135]:
array([4. , 5. , 6.5])
In [136]:
Out[136]:
array([[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]])
In [140]:
Out[140]:
(2, 3, 3)
In [139]:
Out[139]:
array([[[ 1, 2],
[ 4, 5]],
[[10, 11],
[13, 14]]])
In [142]:
Out[142]:
array([[[[8, 4, 9, 0, 2],
[0, 7, 6, 2, 9],
[9, 5, 1, 0, 0],
[9, 1, 1, 5, 3]],
[[2, 0, 4, 8, 7],
[1, 4, 9, 3, 6],
[7, 1, 0, 2, 7],
[0, 0, 9, 8, 2]],
[[0, 5, 5, 0, 9],
[0, 8, 4, 5, 1],
[4, 0, 7, 2, 0],
[3, 9, 8, 3, 7]]],
[[[1, 0, 1, 4, 6],
[1, 0, 1, 0, 1],
[8, 4, 1, 6, 8],
[5, 2, 4, 7, 4]],
[[1, 2, 8, 5, 2],
[9, 6, 2, 5, 7],
[7, 5, 5, 6, 0],
[6, 4, 6, 2, 6]],
[[8, 7, 0, 5, 8],
[9, 7, 7, 6, 2],
[5, 6, 1, 9, 3],
[4, 0, 3, 5, 6]]]])
In [143]:
Out[143]:
((2, 3, 4, 5), 4)
In [147]:
Out[147]:
array([[[[8],
[0],
[9],
[9]],
[[2],
[1],
[7],
[0]],
[[0],
[0],
[4],
[3]]],
[[[1],
[1],
[8],
[5]],
[[1],
[9],
[7],
[6]],
[[8],
[9],
[5],
[4]]]])
4. Manipulating & comparing arrays
Arithmetic
In [166]:
Out[166]:
array([1, 2, 3])
In [168]:
Out[168]:
array([1., 1., 1.])
In [169]:
Out[169]:
array([2., 3., 4.])
In [170]:
Out[170]:
array([0., 1., 2.])
In [171]:
Out[171]:
array([1., 2., 3.])
In [174]:
Out[174]:
array([1, 2, 3])
In [172]:
Out[172]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [173]:
Out[173]:
array([[ 1. , 4. , 9.9],
[ 4. , 10. , 19.5]])
In [176]:
Out[176]:
array([[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]])
In [177]:
Out[177]:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-177-37d8620f1b2c> in <module>
----> 1 a2 * a3
ValueError: operands could not be broadcast together with shapes (2,3) (2,3,3)
In [178]:
Out[178]:
array([1., 2., 3.])
In [180]:
Out[180]:
array([[1. , 1. , 1.1 ],
[4. , 2.5 , 2.16666667]])
In [179]:
Out[179]:
array([[1., 1., 1.],
[4., 2., 2.]])
In [182]:
Out[182]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [181]:
Out[181]:
array([[ 1. , 4. , 10.89],
[16. , 25. , 42.25]])
In [184]:
Out[184]:
array([[ 1. , 4. , 10.89],
[16. , 25. , 42.25]])
In [186]:
Out[186]:
array([2., 3., 4.])
In [185]:
Out[185]:
array([2., 3., 4.])
In [187]:
Out[187]:
array([1, 0, 1])
In [188]:
Out[188]:
array([0.5, 1. , 1.5])
In [189]:
Out[189]:
array([[1. , 0. , 1.3],
[0. , 1. , 0.5]])
In [190]:
Out[190]:
array([ 2.71828183, 7.3890561 , 20.08553692])
In [191]:
Out[191]:
array([0. , 0.69314718, 1.09861229])
Aggregation
Aggregation = performing the same operation on a number of things
In [193]:
Out[193]:
list
In [194]:
Out[194]:
6
In [197]:
Out[197]:
6
In [198]:
Out[198]:
6
Use Python's methods (sum()
) on Python datatypes and use NumPy's methods on NumPy arrays (np.sum()
).
In [199]:
Out[199]:
100000
In [201]:
Out[201]:
array([0.67959677, 0.44959741, 0.3896631 , 0.66184575, 0.01048353,
0.26151906, 0.75223629, 0.93748825, 0.67568463, 0.49847177])
In [202]:
Out[202]:
17.9 ms ± 2.94 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
34 µs ± 391 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
In [203]:
Out[203]:
526.4705882352941
In [204]:
Out[204]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [205]:
Out[205]:
3.6333333333333333
In [206]:
Out[206]:
6.5
In [207]:
Out[207]:
1.0
Standard deviation and variance are measures of 'spread' of data.
The higher standard deviation and the higher variance of data, the more spread out the values are.
The lower standard deviation and lower variance, the less spread out the values are.
In [208]:
Out[208]:
1.8226964152656422
In [209]:
Out[209]:
3.3222222222222224
In [210]:
Out[210]:
1.8226964152656422
In [211]:
In [212]:
Out[212]:
(4296133.472222221, 8.0)
In [213]:
Out[213]:
(2072.711623024829, 2.8284271247461903)
In [215]:
Out[215]:
(1600.1666666666667, 6.0)
In [217]:
Out[217]:
In [218]:
Out[218]:
Reshaping & transposing
In [220]:
Out[220]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [221]:
Out[221]:
(2, 3)
In [222]:
Out[222]:
array([[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]])
In [223]:
Out[223]:
(2, 3, 3)
In [224]:
Out[224]:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-224-37d8620f1b2c> in <module>
----> 1 a2 * a3
ValueError: operands could not be broadcast together with shapes (2,3) (2,3,3)
In [226]:
Out[226]:
(2, 3)
In [228]:
Out[228]:
(2, 3, 1)
In [229]:
Out[229]:
(2, 3, 3)
In [244]:
Out[244]:
array([[[1. ],
[2. ],
[3.3]],
[[4. ],
[5. ],
[6.5]]])
In [231]:
Out[231]:
array([[[ 1. , 2. , 3. ],
[ 8. , 10. , 12. ],
[ 23.1, 26.4, 29.7]],
[[ 40. , 44. , 48. ],
[ 65. , 70. , 75. ],
[104. , 110.5, 117. ]]])
In [233]:
Out[233]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [235]:
Out[235]:
(2, 3)
In [232]:
Out[232]:
array([[1. , 4. ],
[2. , 5. ],
[3.3, 6.5]])
In [234]:
Out[234]:
(3, 2)
In [236]:
Out[236]:
array([[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]])
In [237]:
Out[237]:
(2, 3, 3)
In [239]:
Out[239]:
array([[[ 1, 10],
[ 4, 13],
[ 7, 16]],
[[ 2, 11],
[ 5, 14],
[ 8, 17]],
[[ 3, 12],
[ 6, 15],
[ 9, 18]]])
In [240]:
Out[240]:
(3, 3, 2)
Dot product
In [256]:
Out[256]:
array([[5, 0, 3],
[3, 7, 9],
[3, 5, 2],
[4, 7, 6],
[8, 8, 1]])
In [257]:
Out[257]:
array([[6, 7, 7],
[8, 1, 5],
[9, 8, 9],
[4, 3, 0],
[3, 5, 0]])
In [258]:
Out[258]:
((5, 3), (5, 3))
In [260]:
Out[260]:
array([[5, 0, 3],
[3, 7, 9],
[3, 5, 2],
[4, 7, 6],
[8, 8, 1]])
In [261]:
Out[261]:
array([[6, 7, 7],
[8, 1, 5],
[9, 8, 9],
[4, 3, 0],
[3, 5, 0]])
In [259]:
Out[259]:
array([[30, 0, 21],
[24, 7, 45],
[27, 40, 18],
[16, 21, 0],
[24, 40, 0]])
In [262]:
Out[262]:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-262-0da3c94cc631> in <module>
1 # Dot product
----> 2 np.dot(mat1, mat2)
<__array_function__ internals> in dot(*args, **kwargs)
ValueError: shapes (5,3) and (5,3) not aligned: 3 (dim 1) != 5 (dim 0)
In [263]:
Out[263]:
array([[5, 3, 3, 4, 8],
[0, 7, 5, 7, 8],
[3, 9, 2, 6, 1]])
In [266]:
Out[266]:
((5, 3), (3, 5))
In [267]:
Out[267]:
array([[ 51, 55, 72, 20, 15],
[130, 76, 164, 33, 44],
[ 67, 39, 85, 27, 34],
[115, 69, 146, 37, 47],
[111, 77, 145, 56, 64]])
In [268]:
Out[268]:
(5, 5)
Dot product exmaple (nut butter sales)
In [269]:
Out[269]:
array([[12, 15, 0],
[ 3, 3, 7],
[ 9, 19, 18],
[ 4, 6, 12],
[ 1, 6, 7]])
In [270]:
Out[270]:
In [271]:
Out[271]:
array([10, 8, 12])
In [273]:
Out[273]:
(3,)
In [274]:
Out[274]:
In [279]:
Out[279]:
(3,)
In [278]:
Out[278]:
(5, 3)
In [276]:
Out[276]:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-276-e4058314ac09> in <module>
----> 1 total_sales = prices.dot(sales_amounts)
ValueError: shapes (3,) and (5,3) not aligned: 3 (dim 0) != 5 (dim 0)
In [281]:
Out[281]:
array([240, 138, 458, 232, 142])
In [284]:
Out[284]:
((1, 3), (5, 3))
In [286]:
Out[286]:
(3, 5)
In [292]:
Out[292]:
(1, 5)
In [293]:
Out[293]:
(5, 3)
In [288]:
Out[288]:
In [291]:
Out[291]:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/Desktop/ml-course/sample-project/env/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2896 try:
-> 2897 return self._engine.get_loc(key)
2898 except KeyError:
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'Total ($)'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
~/Desktop/ml-course/sample-project/env/lib/python3.7/site-packages/pandas/core/internals/managers.py in set(self, item, value)
1068 try:
-> 1069 loc = self.items.get_loc(item)
1070 except KeyError:
~/Desktop/ml-course/sample-project/env/lib/python3.7/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2898 except KeyError:
-> 2899 return self._engine.get_loc(self._maybe_cast_indexer(key))
2900 indexer = self.get_indexer([key], method=method, tolerance=tolerance)
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'Total ($)'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-291-d761693dcb57> in <module>
----> 1 weekly_sales["Total ($)"] = daily_sales
2 weekly_sales
~/Desktop/ml-course/sample-project/env/lib/python3.7/site-packages/pandas/core/frame.py in __setitem__(self, key, value)
3470 else:
3471 # set column
-> 3472 self._set_item(key, value)
3473
3474 def _setitem_slice(self, key, value):
~/Desktop/ml-course/sample-project/env/lib/python3.7/site-packages/pandas/core/frame.py in _set_item(self, key, value)
3548 self._ensure_valid_index(value)
3549 value = self._sanitize_column(key, value)
-> 3550 NDFrame._set_item(self, key, value)
3551
3552 # check if we are modifying a copy
~/Desktop/ml-course/sample-project/env/lib/python3.7/site-packages/pandas/core/generic.py in _set_item(self, key, value)
3379
3380 def _set_item(self, key, value):
-> 3381 self._data.set(key, value)
3382 self._clear_item_cache()
3383
~/Desktop/ml-course/sample-project/env/lib/python3.7/site-packages/pandas/core/internals/managers.py in set(self, item, value)
1070 except KeyError:
1071 # This item wasn't present, just insert at end
-> 1072 self.insert(len(self.items), item, value)
1073 return
1074
~/Desktop/ml-course/sample-project/env/lib/python3.7/site-packages/pandas/core/internals/managers.py in insert(self, loc, item, value, allow_duplicates)
1179 new_axis = self.items.insert(loc, item)
1180
-> 1181 block = make_block(values=value, ndim=self.ndim, placement=slice(loc, loc + 1))
1182
1183 for blkno, count in _fast_count_smallints(self._blknos[loc:]):
~/Desktop/ml-course/sample-project/env/lib/python3.7/site-packages/pandas/core/internals/blocks.py in make_block(values, placement, klass, ndim, dtype, fastpath)
3265 values = DatetimeArray._simple_new(values, dtype=dtype)
3266
-> 3267 return klass(values, ndim=ndim, placement=placement)
3268
3269
~/Desktop/ml-course/sample-project/env/lib/python3.7/site-packages/pandas/core/internals/blocks.py in __init__(self, values, placement, ndim)
126 raise ValueError(
127 "Wrong number of items passed {val}, placement implies "
--> 128 "{mgr}".format(val=len(self.values), mgr=len(self.mgr_locs))
129 )
130
ValueError: Wrong number of items passed 5, placement implies 1
In [294]:
Out[294]:
Comparison Operators
In [295]:
Out[295]:
array([1, 2, 3])
In [296]:
Out[296]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [297]:
Out[297]:
array([[False, False, False],
[False, False, False]])
In [299]:
Out[299]:
array([[ True, True, False],
[False, False, False]])
In [301]:
Out[301]:
(numpy.ndarray, dtype('bool'))
In [302]:
Out[302]:
array([False, False, False])
In [303]:
Out[303]:
array([ True, True, True])
In [304]:
Out[304]:
array([ True, True, True])
In [306]:
Out[306]:
array([1, 2, 3])
In [307]:
Out[307]:
array([[1. , 2. , 3.3],
[4. , 5. , 6.5]])
In [305]:
Out[305]:
array([[ True, True, False],
[False, False, False]])
5. Sorting arrays
In [310]:
Out[310]:
array([[7, 8, 1, 5, 9],
[8, 9, 4, 3, 0],
[3, 5, 0, 2, 3]])
In [311]:
Out[311]:
(3, 5)
In [312]:
Out[312]:
array([[1, 5, 7, 8, 9],
[0, 3, 4, 8, 9],
[0, 2, 3, 3, 5]])
In [314]:
Out[314]:
array([[7, 8, 1, 5, 9],
[8, 9, 4, 3, 0],
[3, 5, 0, 2, 3]])
In [313]:
Out[313]:
array([[2, 3, 0, 1, 4],
[4, 3, 2, 0, 1],
[2, 3, 0, 4, 1]])
In [315]:
Out[315]:
array([1, 2, 3])
In [316]:
Out[316]:
array([0, 1, 2])
In [317]:
Out[317]:
0
In [318]:
Out[318]:
2
In [319]:
Out[319]:
array([[7, 8, 1, 5, 9],
[8, 9, 4, 3, 0],
[3, 5, 0, 2, 3]])
In [321]:
Out[321]:
array([1, 1, 1, 0, 0])
In [322]:
Out[322]:
array([4, 1, 1])
6. Practical Example - NumPy in Action!!!!
In [325]:
Out[325]:
<class 'numpy.ndarray'>
In [327]:
Out[327]:
(24465000, (2330, 3500, 3), 3)
In [330]:
Out[330]:
array([[[0.05490196, 0.10588235, 0.06666667],
[0.05490196, 0.10588235, 0.06666667],
[0.05490196, 0.10588235, 0.06666667],
...,
[0.16470589, 0.12941177, 0.09411765],
[0.16470589, 0.12941177, 0.09411765],
[0.16470589, 0.12941177, 0.09411765]],
[[0.05490196, 0.10588235, 0.06666667],
[0.05490196, 0.10588235, 0.06666667],
[0.05490196, 0.10588235, 0.06666667],
...,
[0.16470589, 0.12941177, 0.09411765],
[0.16470589, 0.12941177, 0.09411765],
[0.16470589, 0.12941177, 0.09411765]],
[[0.05490196, 0.10588235, 0.06666667],
[0.05490196, 0.10588235, 0.06666667],
[0.05490196, 0.10588235, 0.06666667],
...,
[0.16470589, 0.12941177, 0.09411765],
[0.16470589, 0.12941177, 0.09411765],
[0.16470589, 0.12941177, 0.09411765]],
[[0.05490196, 0.10588235, 0.06666667],
[0.05490196, 0.10588235, 0.06666667],
[0.05490196, 0.10588235, 0.06666667],
...,
[0.16862746, 0.13333334, 0.09803922],
[0.16862746, 0.13333334, 0.09803922],
[0.16862746, 0.13333334, 0.09803922]],
[[0.05490196, 0.10588235, 0.06666667],
[0.05490196, 0.10588235, 0.06666667],
[0.05490196, 0.10588235, 0.06666667],
...,
[0.16862746, 0.13333334, 0.09803922],
[0.16862746, 0.13333334, 0.09803922],
[0.16862746, 0.13333334, 0.09803922]]], dtype=float32)
In [331]:
Out[331]:
<class 'numpy.ndarray'>
In [333]:
Out[333]:
array([[[0.5019608 , 0.50980395, 0.4862745 , 1. ],
[0.3372549 , 0.34509805, 0.30588236, 1. ],
[0.20392157, 0.21568628, 0.14901961, 1. ],
...,
[0.64705884, 0.7058824 , 0.54901963, 1. ],
[0.59607846, 0.63529414, 0.45882353, 1. ],
[0.44705883, 0.47058824, 0.3372549 , 1. ]]], dtype=float32)
In [334]:
Out[334]:
<class 'numpy.ndarray'>
In [335]:
Out[335]:
array([[[0.70980394, 0.80784315, 0.88235295, 1. ],
[0.72156864, 0.8117647 , 0.8862745 , 1. ],
[0.7411765 , 0.8156863 , 0.8862745 , 1. ],
...,
[0.49803922, 0.6862745 , 0.8392157 , 1. ],
[0.49411765, 0.68235296, 0.8392157 , 1. ],
[0.49411765, 0.68235296, 0.8352941 , 1. ]],
[[0.69411767, 0.8039216 , 0.8862745 , 1. ],
[0.7019608 , 0.8039216 , 0.88235295, 1. ],
[0.7058824 , 0.80784315, 0.88235295, 1. ],
...,
[0.5019608 , 0.6862745 , 0.84705883, 1. ],
[0.49411765, 0.68235296, 0.84313726, 1. ],
[0.49411765, 0.68235296, 0.8392157 , 1. ]],
[[0.6901961 , 0.8 , 0.88235295, 1. ],
[0.69803923, 0.8039216 , 0.88235295, 1. ],
[0.7058824 , 0.80784315, 0.88235295, 1. ],
...,
[0.5019608 , 0.6862745 , 0.84705883, 1. ],
[0.49803922, 0.6862745 , 0.84313726, 1. ],
[0.49803922, 0.6862745 , 0.84313726, 1. ]],
...,
[[0.9098039 , 0.81960785, 0.654902 , 1. ],
[0.8352941 , 0.7490196 , 0.6509804 , 1. ],
[0.72156864, 0.6313726 , 0.5372549 , 1. ],
...,
[0.01568628, 0.07058824, 0.02352941, 1. ],
[0.03921569, 0.09411765, 0.03529412, 1. ],
[0.03921569, 0.09019608, 0.05490196, 1. ]],
[[0.9137255 , 0.83137256, 0.6784314 , 1. ],
[0.8117647 , 0.7294118 , 0.627451 , 1. ],
[0.65882355, 0.5686275 , 0.47843137, 1. ],
...,
[0.00392157, 0.05490196, 0.03529412, 1. ],
[0.03137255, 0.09019608, 0.05490196, 1. ],
[0.04705882, 0.10588235, 0.06666667, 1. ]],
[[0.9137255 , 0.83137256, 0.68235296, 1. ],
[0.76862746, 0.68235296, 0.5882353 , 1. ],
[0.59607846, 0.5058824 , 0.44313726, 1. ],
...,
[0.03921569, 0.10196079, 0.07058824, 1. ],
[0.02745098, 0.08235294, 0.05882353, 1. ],
[0.05098039, 0.11372549, 0.07058824, 1. ]]], dtype=float32)
In [ ]: