np.expand_dims函数

# -*- coding: utf-8 -*-
"""
Created on Wed Nov 21 01:51:42 2018
#QQ群:476842922(欢迎加群讨论学习)
"""
import numpy as np
x = np.array([1,2])
print(x.shape)
print(x)
y = np.expand_dims(x, axis=0)#expand_dims(a, axis)就是在axis的那一个轴上把数据加上去
print(y.shape)
print(y)

n = np.expand_dims(x, axis=1)
print(n.shape) 
print(n)

(2,)
[1 2]
(1, 2)
[[1 2]]
(2, 1)
[[1]
[2]]

猜你喜欢

转载自blog.csdn.net/weixin_33595571/article/details/84312699