# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""
import torch
import numpy as np

x=[2,4,5,6]
y=[2,4,5,6]
z=[]
x_t = torch.tensor([x])
y_t = torch.tensor([y])
print(x_t)
print(y_t)
z+=[2]
z+=[3,4,5]
print(z)
res = torch.cat((x_t,y_t),1)
#print(np.shape(z))
print(res)
c=x_t.add_(y_t)
print(c)

#a=np.arange(5)
#tt='[array([ 0.54264821, -0.03291024, 1.85542024]), array([0.61734337, 0.37156801, 1.67763758]), array([ 0.5940852 , -0.05547193, 1.87491408]), array([0.92780198, 0.56516497, 2.42172674]), array([ 0.59630049, -0.11500818, 1.26347751])]'
#np.save('C:\\Users\\mayn\\Desktop\\test.npy',tt)
#a=np.load('C:\\Users\\mayn\\Desktop\\test.npy')
a1=[np.array([ 0.44264821, -0.03291024, 1.85542024]),
np.array([0.61734337, 0.37156801, 1.67763758]),
np.array([ 0.5940852 , -0.05547193, 1.87491408]),
np.array([0.92780198, 0.56516497, 2.42172674]),
np.array([ 0.59630049, -0.11500818, 1.26347751])]
np.save('C:\\Users\\mayn\\Desktop\\ab.npy',a1)

b=np.load('C:\\Users\\mayn\\Desktop\\ab.npy')
print(b)

输出:

runfile('C:/Users/mayn/.spyder-py3/temp.py', wdir='C:/Users/mayn/.spyder-py3')
tensor([[2, 4, 5, 6]])
tensor([[2, 4, 5, 6]])
[2, 3, 4, 5]
tensor([[2, 4, 5, 6, 2, 4, 5, 6]])
tensor([[ 4, 8, 10, 12]])
[[ 0.44264821 -0.03291024 1.85542024]
[ 0.61734337 0.37156801 1.67763758]
[ 0.5940852 -0.05547193 1.87491408]
[ 0.92780198 0.56516497 2.42172674]
[ 0.59630049 -0.11500818 1.26347751]]