标签:res numpy `` code pre pytho 矩阵 abs 绝对值
import torch
import numpy as np
np_data = np.arange(6).reshape((2,3))
#np ---> torch
torch_data = torch.from_numpy(np_data)
#torch --> np
torch_data_2= torch_data.numpy()
[[0 1 2]
[3 4 5]]
tensor([[0, 1, 2],
[3, 4, 5]])
求绝对值
torch.abs(tensor)
矩阵向乘
torch.mm(tensor,tensor)
```python
data = [-1,-2,1,2]
tensor = torch.FloatTensor(data)
torch.abs(tensor)
标签:res numpy `` code pre pytho 矩阵 abs 绝对值
原文地址:https://www.cnblogs.com/liu247/p/11145504.html