np.newaxis——np.ndarray增加维数
生活随笔
收集整理的這篇文章主要介紹了
np.newaxis——np.ndarray增加维数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
numpy.newaxis
The newaxis object can be used in all slicing operations to create an axis of length one. newaxis is an alias for ‘None’, and‘None’can be used in place of this with the same result.
newaxis是None的一個別名。
實例
import numpy as np x = np.array([[1,2,3],[4,5,6],[7,8,9]]) a = x[:,np.newaxis,:] b = x[:,:,np.newaxis] print a print b輸出
注意:np.newaxis的位置對數組的改變,常用于從數據中取列的操作中
總結
以上是生活随笔為你收集整理的np.newaxis——np.ndarray增加维数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 机器学习——KNN实现
- 下一篇: cuda7.5 和cuda8共存