1.生成数据
import torch
import numpy as np
data = []
for i in range(20000):
x=[]
y=[]
for i in range(16384):
a = np.random.normal(loc=0.0, scale=14, size=None)
b = np.random.normal(loc=0.0, scale=14, size=None)
y.append(b)
x.append(a)
x_min = min(x)
x_max = max(x)
y_min = min(y)
y_max = max(y)
for i in range(16384):
x[i] = (x[i] - x_min) / (x_max - x_min)
y[i] = (y[i] - y_min) / (y_max - y_min)
X = np.array(x).reshape(128, 128)
Y = np.array(y).reshape(128, 128)
matrix_A = np.array([X,Y])
neg_tensor = torch.FloatTensor(matrix_A)
neg_tensor = (neg_tensor, 0)
data.append(neg_tensor)
torch.save(data, "./output-set/train_data.pth") #D:\python\project\Artificialgan\ArtificialGANFingerprints-main\output-set\data.pth
以上是生成了20000条数据,每条数据是两个通道128*128=16384
2.读取数据
import torch
y = torch.load("D:\python\project\Artificialgan\ArtificialGANFingerprints-main\output-set\data.pth")
print(y)