Tensorflow 3D数据的DataGenerator中是否存在任何问题?

Tensorflow 3D数据的DataGenerator中是否存在任何问题?,tensorflow,keras,Tensorflow,Keras,我尝试使用DataGenerator进行3D数据集。但我犯了一些错误 类DataFeedGenerator(tf.keras.utils.Sequence): 该错误是否仅发生在第208批中? 考虑到您的形状和批次大小,批次总数应为15000/32=468,因为您的总数为245,这意味着您给出的批次大小为61?对吗? 而且 self.currentX1=无 self.currentX2=无 self.currentY=None ... self.currentX1=self.X1[索引*自批大

我尝试使用DataGenerator进行3D数据集。但我犯了一些错误

类DataFeedGenerator(tf.keras.utils.Sequence):


该错误是否仅发生在第208批中?
考虑到您的形状和批次大小,批次总数应为15000/32=468,因为您的总数为245,这意味着您给出的批次大小为61?对吗?
而且

self.currentX1=无
self.currentX2=无
self.currentY=None
...
self.currentX1=self.X1[索引*自批大小:(索引+1)*自批大小]
self.currentX2=self.X2[索引*自批大小:(索引+1)*自批大小]
self.currentY=self.Y[索引*自批大小:(索引+1)*自批大小]
返回[self.currentX1,self.currentX2],self.currentY
为什么要使用class属性,只能使用局部变量current\u x1,current\u x2…
我还将把uu len uu写为:

def\uuuu len\uuuu(自):
返回数学单元(len(self.X1)/self.batch\u大小)

这里是生成代码。trainingGen=数据馈送生成器(X1\u系列、X2\u系列、y\u系列、批次大小=批次大小,name=“Training Gen”)。X1_系列和X2_系列的尺寸为(15000,44,52,52,1)。
def __init__(self,x1,x2,y,batch_size=32, dim=(44,52,52,1), n_channels=1, n_classes=1, shuffle=True, name="Training"):
    self.dim = dim
    self.batch_size = batch_size
    self.Y = y
    self.X1 = x1
    self.X2 = x2
    self.currentX1 = None
    self.currentX2 = None
    self.currentY = None
    self.batch_index = 0
    self.n_channels = n_channels
    self.classes = n_classes
    self.shuffle = shuffle
    self.name = name

def __len__(self):
    n = math.ceil(self.X1.shape[0] / self.batch_size)
    print(self.name, "__len__", n)
    return n


def __getitem__(self,index):
    self.currentX1 = self.X1[index * self.batch_size:(index + 1) * self.batch_size]
    self.currentX2 = self.X2[index * self.batch_size:(index + 1) * self.batch_size]
    self.currentY = self.Y[index * self.batch_size:(index + 1) * self.batch_size]

    return [self.currentX1, self.currentX2], self.currentY