2016-10-14 6 views

答えて

0

ルックを返すていません配列そのもの。それは自明でなければなりません。

>>> d 
array([[[[ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.]], 

     [[ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.]]]]) 
# first you grab the first and only element 
>>> d[0] 
array([[[ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.]], 

     [[ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.]]]) 
# then you get the first element out of the two groups 
>>> d[0][0] 
array([[ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.]]) 
# thirdly, you get the two first elements as a list 
>>> d[0][0][0:2] 
array([[ 1., 1., 1., 1.], 
     [ 1., 1., 1., 1.]]) 
# finally, you get the first element of the list 
>>> d[0][0][0:2][0] 
array([ 1., 1., 1., 1.]) 
+0

私は愚かになります。私は欲しいものがd [0,0,0:2,0]であることを知ります。ありがとう! – NormanOu

+0

ああ、私は今あなたが望むものを見る...スライスの詳細:https://docs.python.org/2.3/whatsnew/section-slices.html – mk2

+0

また、1秒ではなくこの配列構成を使用することもできます。 .. d = np.arange(1 * 2 * 3 * 4).reshape(1,2,3,4)...あなたが戻ってきたものを見るのが簡単になります。 – NaN

関連する問題