Keras 的Model.fit_generator 报错 StopIteration

要在generator函数部分加上while 1

def gen():
    while 1:
        data = h5py.File('D:/《桌面》/CDL-500.mat', 'r')
        i = 0
        while True:
            x_train = data['x_train'][i*20: (i+1)*20]
            y_train = data['y_train'][i*20: (i+1)*20]
            yield (x_train, y_train)
            i += 1
            if i >= 5:
                break

参考:https://blog.csdn.net/Will_Ye/article/details/103213904

你可能感兴趣的:(Keras 的Model.fit_generator 报错 StopIteration)