Numpy-inner

提供:Dev Guides
移動先:案内検索

numpy.inner()

この関数は、1次元配列のベクトルの内積を返します。 高次元の場合、最後の軸の合計積を返します。

import numpy as np
print np.inner(np.array([1,2,3]),np.array([0,1,0]))
# Equates to 1*0+2*1+3*0

それは次の出力を生成します-

2

# Multi-dimensional array example
import numpy as np
a = np.array([[print 'Array a:'
print a
b = np.array([[print 'Array b:'
print b

print 'Inner product:'
print np.inner(a,b)

それは次の出力を生成します-

Array a:
[[Array b:
[[Inner product:
[[In the above case, the inner product is calculated as −

[source,result,notranslate]

1 11 + 2 12、1 13 + 2 14 3 11 + 4 12、3 13 + 4 14