在keras中创建图像生成器和训练模型

时间:2018-11-20 10:53:47

标签: python keras conv-neural-network

在下面的代码中,我得到以下错误:@Repository public interface AuditLogRepository extends JpaRepository<AuditLog, Long>{ List<AuditLog> findByAction(AuditActionType action); } 。这将是代码中给出的第一个参数吗?谁能解释为什么我仍然遇到此错误以及如何解决?

x_train的形状为(400,256,256,4)dtype = float64。 y_train是形状(400、256、256)dtype = uint8。

x_val的形状为(100,256,256,4)dtype = float64。 y_val是形状(100、256、256)dtype = uint8。

TypeError: fit_generator() missing 1 required positional argument: 'generator'

具有回溯的完整错误如下:

    # Create image generator
data_gen_args = dict(rotation_range=5,
                     width_shift_range=0.1,
                     height_shift_range=0.1,
                     validation_split=0.2)
image_datagen = ImageDataGenerator(**data_gen_args)

seed = 1
batch_size = 4

def XYaugmentGenerator(X1, y, seed, batch_size):
    genX1 = gen.flow(X1, y, batch_size=batch_size, seed=seed)
    genX2 = gen.flow(y, X1, batch_size=batch_size, seed=seed)
    while True:
        X1i = genX1.next()
        X2i = genX2.next()

        yield X1i[0], X2i[0]


# Train model
Model.fit_generator(XYaugmentGenerator(x_train, y_train, seed, batch_size), steps_per_epoch=np.ceil(float(len(images)) / float(batch_size)),
                validation_data = XYaugmentGenerator(x_val, y_val,seed, batch_size), 
                validation_steps = np.ceil(float(len(x_val)) / float(batch_size))
, shuffle=True, epochs=20)

0 个答案:

没有答案