#nn.Linear的操作是torch.mm(h_t, torch.transpose(weight,1,0)) layer = nn.Linear( in_features=4, out_features=4,bias = False ) transformed_h_t = layer(h_t) params = list(layer.named_parameters()) print(params[0]) print("transformed_h_t",transformed_h_t) weight = torch.tensor([[ 0.4935, -0.2656, 0.4077, -0.4063], [-0.1951, 0.2847, -0.4069, -0.0827], [-0.4420, 0.1278, 0.2191, -0.3036], [-0.3300, -0.2710, 0.2737, 0.2945]]) # bias = torch.tensor([-0.1908, -0.1736, 0.2886, 0.0754]) print(torch.transpose(weight,1,0)) h_t_mm = torch.mm(h_t, torch.transpose(weight,1,0)) print("h_t_mm",h_t_mm)
2020-09-15
最新推荐文章于 2023-11-24 15:42:23 发布