網(wǎng)站首頁 編程語言 正文
pytorch常用函數(shù)torch.randn()
torch.randn(*sizes, out=None) → Tensor
功能:從標(biāo)準(zhǔn)正態(tài)分布(均值為0,方差為1)中抽取的一組隨機(jī)數(shù)。返回一個張量
-
sizes (int…)
- 整數(shù)序列,定義輸出張量的形狀 -
out (Tensor, optinal)
- 結(jié)果張量
eg:
random = torch.randn(2, 3) out: ?0.5419 0.1594 -0.0413 ? ? ? ? -2.7937 0.9534 0.4561
pytorch torch.chunk(tensor, chunks, dim)
說明:在給定的維度上講張量進(jìn)行分塊。
參數(shù):
-
tensor(Tensor)
-- 待分塊的輸入張量 -
chunks(int)
-- 分塊的個數(shù) -
dim(int)
-- 維度,沿著此維度進(jìn)行分塊
>>> x = torch.randn(3, 3) >>> x tensor([[ 1.0103, ?2.3358, -1.9236], ? ? ? ? [-0.3890, ?0.6594, ?0.6664], ? ? ? ? [ 0.5240, -1.4193, ?0.1681]]) >>> torch.chunk(x, 3, dim=0) (tensor([[ 1.0103, ?2.3358, -1.9236]]), tensor([[-0.3890, ?0.6594, ?0.6664]]), tensor([[ 0.5240, -1.4193, ?0.1681]])) >>> torch.chunk(x, 3, dim=1) (tensor([[ 1.0103], ? ? ? ? [-0.3890], ? ? ? ? [ 0.5240]]), tensor([[ 2.3358], ? ? ? ? [ 0.6594], ? ? ? ? [-1.4193]]), tensor([[-1.9236], ? ? ? ? [ 0.6664], ? ? ? ? [ 0.1681]])) >>> torch.chunk(x, 2, dim=1) (tensor([[ 1.0103, ?2.3358], ? ? ? ? [-0.3890, ?0.6594], ? ? ? ? [ 0.5240, -1.4193]]), tensor([[-1.9236], ? ? ? ? [ 0.6664], ? ? ? ? [ 0.1681]]))
總結(jié)
原文鏈接:https://blog.csdn.net/JannyYang/article/details/100514037
相關(guān)推薦
- 2022-11-13 淘寶NPM鏡像 & cnpm
- 2022-01-04 變量提升,函數(shù)提升及其優(yōu)先級關(guān)系
- 2022-11-02 Python中turtle庫常用代碼匯總_python
- 2022-10-01 使用301永久重定向和302臨時重定向作用區(qū)別詳解_相關(guān)技巧
- 2023-03-03 PostgreSQL時間日期的語法及注意事項_PostgreSQL
- 2022-09-08 pytest實現(xiàn)多進(jìn)程與多線程運(yùn)行超好用的插件_python
- 2022-08-10 pandas數(shù)據(jù)清洗實現(xiàn)刪除的項目實踐_python
- 2022-11-05 python?pandas?query的使用方法_python
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支