chainer.functions.get_item(x, slices)[source]

配列から指定されたshape、軸、オフセットの要素を抽出する。

 

Parameters:
  • x (Variable) – スライスされるもとの変数。
  • slices (int, slice, Ellipsis, None, integer array-like, boolean array-like or tuple of them) –整数、スライス、エリプシス、numpy.newaxis,  array-likeな整数、 array-likeな真偽値もしくはそれらのタプル。
Returns:

 x.をスライスした配列を含むVariable オブジェクト 。

 

Note
slicesに整数配列が含まれている場合、CUDAのatomicADD関数によってサポートされている型のみサポートします。サポートされている型とは、 numpy.float32、 numpy.int32、 numpy.uint32、 numpy.uint64numpy.ulonglongです。

 

Note
複数の真偽値の配列を含む slices はサポートしていません。

 

Note
詳細はNumpyのドキュメントの indexingをお読みください。

Example

 

 



>>> x1 = np.array((1, 2, 3))

>>> x1.shape (3,)
>>> x2 = np.array((2, 3, 4))
>>> x2.shape (3,)
>>> y = F.hstack((x1, x2))
>>> y.shape (6,)
>>> y.data
array([1, 2, 3, 2, 3, 4])
>>> x1 = np.arange(0, 12).reshape(3, 4)
>>> x1.shape (3, 4)
>>> x1
array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]])
>>> x2 = np.arange(12, 18).reshape(3, 2)
>>> x2.shape (3, 2)
>>> x2
array([[12, 13], [14, 15], [16, 17]])
>>> y = F.hstack([x1, x2])
>>> y.shape (3, 6)
>>> y.data
array([[ 0, 1, 2, 3, 12, 13], [ 4, 5, 6, 7, 14, 15], [ 8, 9, 10, 11, 16, 17]])