摘要: Broadcasting是一种没有copy数据的expand Key idea: - 不过两个维度不相同,在前面插入维度1 - 扩张维度1到相同的维度 例如:Feature maps:[4,32,14,14] Bias:[32,1,1]=>[1,32,1,1]=>[4,32,14,14] A:[32 阅读全文
posted @ 2023-07-30 22:19 哎呦哎(iui) 阅读(14) 评论(0) 推荐(0) 编辑
摘要: ▪ View/reshape(这个是维度的变化) ▪ Squeeze/unsqueeze(维度的增加/减少) ▪ Transpose/t/permute(维度交换) ▪ Expand/repeat(维度的扩展) # view/reshape 这两个API,都是通用的a.reshape()和a.vie 阅读全文
posted @ 2023-07-30 19:02 哎呦哎(iui) 阅读(29) 评论(0) 推荐(0) 编辑
摘要: # indexing ``` a=torch.randn(4,3,28,28) a[0].shape # torch.Size([3, 28, 28]) a[0,0].shape # torch.Size([28, 28]) a[0,0,2,4] # tensor(0.6574) ``` # sel 阅读全文
posted @ 2023-07-30 16:15 哎呦哎(iui) 阅读(12) 评论(0) 推荐(0) 编辑
摘要: # Import from numpy >torch.from_numpy(data) ``` a=np.array([2,3.3]) a #array([2. , 3.3]) torch.from_numpy(a) #tensor([2.0000, 3.3000], dtype=torch.flo 阅读全文
posted @ 2023-07-30 10:52 哎呦哎(iui) 阅读(16) 评论(0) 推荐(0) 编辑