在Python中为CSV数据集创建辅助GAN模型时出现错误

时间:2020-03-29 11:09:02

标签: python tensorflow keras deep-learning generative-adversarial-network

我正在尝试为CSV数据集生成生成器和鉴别器。 我在哪里构建辅助生成对抗网络(GAN)模型 但是在编码时会遇到一些错误。 请帮助解决这些错误。 我愿意接受所有人的建议。预先感谢您检查我的问题

发电机

class Item
{
    Ingredient ingredient;
    int quantity;
}

class Recipe extends Ingredient
{
    List<Item> items;
}

鉴别器

def create_generator():
    generator=Sequential()
    generator.add(Dense(units=64,input_dim=10))
    generator.add(LeakyReLU(0.2))

    generator.add(Dense(units=128))
    generator.add(LeakyReLU(0.2))

    generator.add(Dense(units=256))
    generator.add(LeakyReLU(0.2))


    generator.add(Dense(units=44, activation='tanh'))

    generator.compile(loss='binary_crossentropy', optimizer=Adam(lr=0.001, beta_1=0.5))
    return generator

> 错误


def create_discriminator():

    discriminator = Sequential()
    discriminator.add(Dense(units = 256,input_dim = 44))
    discriminator.add(LeakyReLU(0.2))
    discriminator.add(Dropout(0.3))


    discriminator.add(Dense(units=128))
    discriminator.add(LeakyReLU(0.2))
    discriminator.add(Dropout(0.3))


    discriminator.add(Dense(units=64))
    discriminator.add(LeakyReLU(0.2))
    discriminator.add(Dropout(0.3))

#     inpu = Input(shape=(44,))

    value = discriminator(Input(shape=(44,)))



#     discriminator.add(Dense(units=1, activation='sigmoid'))
    discriminator_fake = Dense(units=1, activation='sigmoid')(value)
    discriminator_predict = Dense(units=2, activation='softmax')(value)

    model = Model(inputs = Input(shape=(44,)), outputs=[discriminator_fake,discriminator_predict])
#     discriminator.compile(loss='binary_crossentropy', optimizer='adam')

    model.compile(loss=['binary_crossentropy', 'sparse_categorical_crossentropy'], optimizer=Adam(lr=0.001, beta_1=0.5))
    return model

0 个答案:

没有答案