網(wǎng)站首頁 編程語言 正文
pytorch常用函數(shù)torch.randn()
torch.randn(*sizes, out=None) → Tensor
功能:從標準正態(tài)分布(均值為0,方差為1)中抽取的一組隨機數(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)
說明:在給定的維度上講張量進行分塊。
參數(shù):
-
tensor(Tensor)
-- 待分塊的輸入張量 -
chunks(int)
-- 分塊的個數(shù) -
dim(int)
-- 維度,沿著此維度進行分塊
>>> 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-10-30 Redis過期刪除策略與內(nèi)存淘汰策略_Redis
- 2022-08-15 springboot的熱部署配置
- 2022-01-30 h5 uniapp history模式下刷新頁面404
- 2022-12-22 C++模擬實現(xiàn)STL容器vector的示例代碼_C 語言
- 2023-07-05 Maven的-pl -am -amd參數(shù)
- 2022-10-11 oracle 12c和plsql的詳細安裝和配置過程(超級詳細,小白也能懂)
- 2022-11-12 asp.net?web?api2設(shè)置默認啟動登錄頁面的方法_實用技巧
- 2022-07-15 SQL?Server分頁方法匯總_MsSql
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- 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被代理目標對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支