import torch
import numpy as np
a = np.array([[1,2],[3,4]])
a1 = torch.from_numpy(a)
prev_weight, next_weight = a1[:, 0], a1[:, 1]
print("a1:")
print(a1)
print("prev_weight:")
print(prev_weight)
print("next_weight:")
print(next_weight)
输出:
a1:
tensor([[1, 2],
[3, 4]])
prev_weight:
tensor([1, 3])
next_weight:
tensor([2, 4])