Python深度学习 第二版学习记录

Python深度学习 第二版学习记录,第1张

扩展数据的维度 expand_dims
#横向
y=[1,2,3]
y = np.expand_dims(y, axis=0)
y

输出结果:
array([[1, 2, 3]])

# 纵向
y=[1,2,3]
y = np.expand_dims(y, axis=1)
y

输出结果:
array([[1],
[2],
[3]])
2. concatenate 拼接

y=("a","b","c")
Y = np.concatenate([y] * 32, axis=0)
Y

输出结果
array([‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’,
‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’,
‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’,
‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’,
‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’,
‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’,
‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’, ‘b’, ‘c’, ‘a’,
‘b’, ‘c’, ‘a’, ‘b’, ‘c’], dtype=‘

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/939677.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-17
下一篇 2022-05-17

发表评论

登录后才能评论

评论列表(0条)

保存