Slide 27
Slide 27 text
27
>>> a = numpy.arange(9).reshape(3,3)
>>> a
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
>>> a[[0,1],[0,1]]
array([0, 4])
irb> a = Numo::SFloat.new(3,3).seq
=> Numo::SFloat#shape=[3,3]
[[0, 1, 2],
[3, 4, 5],
[6, 7, 8]]
irb> a[[0,1],[0,1]]
=> Numo::SFloat(view)#shape=[2,2]
[[0, 1],
[3, 4]]
irb> a[[0,1],[0,1]].diagonal
=> Numo::SFloat(view)#shape=[2]
[0, 4]
Future Works
Performance Improvement
(2) Difference in Advanced Indexing
(3) Fix any other places using to_a, each, or map in red chainer.