np.broadcast_to()的函数使用及维度增加的表达
2024-09-08 10:30:28
import numpy as np
anchors=np.ones((2,3))
anchor = np.broadcast_to(anchors, (5,)+anchors.shape) # 标红字体表达较为新颖(个人认为)
print(anchor)
print('anchors=',anchor.shape)
print('(5,)+anchors.shape=',(5,)+anchors.shape)
print('(4,)+(5,)+anchors.shape=',(4,)+(5,)+anchors.shape) 结果如下:
[[[1. 1. 1.]
[1. 1. 1.]]
[[1. 1. 1.]
[1. 1. 1.]]
[[1. 1. 1.]
[1. 1. 1.]]
[[1. 1. 1.]
[1. 1. 1.]]
[[1. 1. 1.]
[1. 1. 1.]]]
anchors= (5, 2, 3)
(5,)+anchors.shape= (5, 2, 3)
(4,)+(5,)+anchors.shape= (4, 5, 2, 3)
最新文章
- jQuery Colorbox弹窗插件使用教程小结、属性设置详解
- js == 与 === 的区别,‘’与“”的区别
- oracle11g的standby性能分析报告statpack安装
- Redis 下载
- Python字符串基础操作
- 解读 Windows Azure 存储服务的账单 – 带宽、事务数量,以及容量
- Show Global Status 整理
- eclipse tomcat内存设置
- 关于$.ajax的请求格式
- ASP.NET Core 返回 Json DateTime 格式
- 搭建 structs2 环境
- 20155324王鸣宇安装虚拟机+初次学习Linux的感想20155324
- 深入NAS协议系列: 召唤SMB2 OpLock/Lease
- scons, cmake, bazel
- 分布式实时日志系统(四) 环境搭建之centos 6.4下hbase 1.0.1 分布式集群搭建
- virtualbox+vagrant学习-5-Boxes-2-Box Versioning
- eclipse启动几秒后报错 (一闪而过)
- boost::io_service解读
- BZOJ 1604 [Usaco2008 Open]Cow Neighborhoods 奶牛的邻居:队列 + multiset + 并查集【曼哈顿距离变形】
- 示例的libevent的程序