1、将数据归一化到(a,b)区间
(1)首先找到原本样本数据X的最小值Min及最大值Max
(2)计算系数:k=(b-a)/(Max-Min)
(3)得到归一化到[a,b]区间的数据:Y=a+k(X-Min) 或者 Y=b+k(X-Max)
2、报错:UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor.
# 修改前 x_train = torch.Tensor([binary_encode(number) for number in range(101, 1024)]) # 把数转成10位二进制
# 修改后 x_train = torch.Tensor(np.array([binary_encode(number) for number in range(101, 1024)]))
3\取tensor某一维度
a.size(0)
标签:10,tensor,Min,Max,number,22.11,numpy From: https://www.cnblogs.com/lixinyu0310/p/16877934.html