修改的wgan代码

基于《Python深度学习》中的GAN代码,作者进行了个人理解的修改,实验结果显示性能显著提升。
摘要由CSDN通过智能技术生成

对《Python深度学习》的GAN源码,根据自己的理解做了些许修改,发现性能提高很多。

import keras
from keras.constraints import min_max_norm
from keras import layers, initializers
import numpy as np
import os
from keras.preprocessing import image
from keras import backend as K


def wasserstein(y_true, y_pred):
    return K.mean(y_true * y_pred)


batch_size = 64
latent_dim = 32
height = 32
width = 32
s = 32
channels = 3
Citers = 5

start_dim = 2

c = 0.01
lr_G = 5e-5
lr_D = 5e-5

f = 512
reshape_shape = (start_dim, start_dim, f)

generator_input = keras.Input(shape=(latent_dim,))

x = layers.Dense(f * start_dim * start_dim, use_bias=False)(generator_input)
x = layers.BatchNormalization(axis=-1)(x)
x = layers.LeakyReLU()(x)
x = layers.Reshape(reshape_shape)(x)

for i in range(3):
    nb_filters = int(f / (2 ** (i + 1)))
    x = layers.Deconv2D(nb_filters, (3, 3), 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值