美文网首页
numpy中一些超有用的函数

numpy中一些超有用的函数

作者: 铭小狮子酱 | 来源:发表于2020-05-29 03:33 被阅读0次
  1. expand_dims
    比如 x = np.array([1,2])shape(2,). 拓展为行向量:
>>> y = np.expand_dims(x, axis=0)
>>> y
array([[1, 2]])
>>> y.shape
(1, 2)

拓展为列向量

>>> y = np.expand_dims(x, axis=0)
>>> y
array([[1],
       [2]])
>>> y.shape
(2, 1)

相关文章

网友评论

      本文标题:numpy中一些超有用的函数

      本文链接:https://www.haomeiwen.com/subject/prutzhtx.html