Numpy-squeeze

提供:Dev Guides
2020年6月23日 (火) 03:12時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

numpy.squeeze

この関数は、指定された配列の形状から1次元のエントリを削除します。 この機能には2つのパラメーターが必要です。

numpy.squeeze(arr, axis)

どこで、

Sr.No. Parameter & Description
1

arr

入力配列

2

axis

intまたはintのタプル。 形状の単一次元エントリのサブセットを選択します

import numpy as np
x = np.arange(9).reshape(1,3,3)

print 'Array X:'
print x
print '\n'
y = np.squeeze(x)

print 'Array Y:'
print y
print '\n'

print 'The shapes of X and Y array:'
print x.shape, y.shape

その出力は次のとおりです-

Array X:
[[Array Y:
[[The shapes of X and Y array:
(1, 3, 3) (3, 3)