import torch list_4d = torch.rand(4, 5, 5, 5) list_2d = torch.rand(5, 5) list_4d[..., -1] = list_4d[..., -1] * list_2d matrix_4d = torch.sum(list_4d, dim=-1)
我需要一段python的pytorch版本代码,四维列表和二维列表变成矩阵,四维矩阵最后一维的尺寸为5与二维矩阵的行和列尺寸为5,四维矩阵的最后一维单独乘以二维矩阵,其他维度数据不变...
最新推荐文章于 2023-04-12 01:20:10 发布