예제 #1
0
def init_data(mode):
    global CLASS_NUM, BATCH_SIZE, inet, cifar_data, data_set, dp, config_name, raw_cifar
    assert mode in ["train", "eval"]
    CLASS_NUM = settings.config["CLASS_NUM"]
    BATCH_SIZE = settings.config["BATCH_SIZE"]
    data_set = settings.config["data_set"]
    config_name = settings.config["config_name"]

    assert data_set in ["cifar10", "svhn", "imagenet"]
    data_set = data_set

    if data_set == "imagenet":
        if mode == "train":
            inet = imagenet(BATCH_SIZE, dataset="train")
        elif mode == "eval":
            inet = imagenet(BATCH_SIZE, dataset="val")
    elif data_set == "cifar10":

        raw_cifar = cifar10_input.CIFAR10Data("cifar10_data")
        if mode == "eval":
            cifar_data = raw_cifar.eval_data
        elif mode == "train":
            cifar_data = raw_cifar.train_data
    else:
        assert False, "Not implemented"
    dp = datapair(CLASS_NUM, BATCH_SIZE)
    #LR_DECAY_RATE = 1e-5  # 5e-5
    DECAY_STEPS = 1.0
    adv_weight = 128
    ITER = 100

style_weight = 1

if data_set == "cifar10":
    raw_cifar = cifar10_input.CIFAR10Data("cifar10_data")

    def get_data(sess):
        x_batch, y_batch = raw_cifar.train_data.get_next_batch(
            batch_size=BATCH_SIZE, multiple_passes=True)
        return x_batch, y_batch
elif data_set == "imagenet":
    inet = imagenet(BATCH_SIZE, dataset="train")

    def get_data(sess):
        x_batch, y_batch = inet.get_next_batch(sess)

        return x_batch, y_batch


ENCODER_WEIGHTS_PATH = 'vgg19_normalised.npz'
if data_set == "cifar10":
    Decoder_Model = "./trans_pretrained/cifar10transform1.ckpt-574000"  #'transform2.ckpt-147000'#./trans_pretrained/transform.ckpt'
elif data_set == "imagenet":
    if data_set_name == "imagenet_shallow":
        Decoder_Model = "./imagenetshallowtransform1.ckpt.mode2"
    elif data_set_name == "imagenet_shallowest":
        Decoder_Model = "./imagenetshallowesttransform1.ckpt.mode2"
예제 #3
0
    LEARNING_RATE = 1e-3
    LR_DECAY_RATE = 1e-5  # 5e-5
    DECAY_STEPS = 1.0
    adv_weight = 12  #128
    ITER = 1000
style_weight = 1

if data_set == "cifar10":
    raw_cifar = cifar10_input.CIFAR10Data("cifar10_data")

    def get_data(sess):
        x_batch, y_batch = raw_cifar.train_data.get_next_batch(
            batch_size=BATCH_SIZE, multiple_passes=True)
        return x_batch, y_batch
elif data_set == "imagenet":
    inet = imagenet(BATCH_SIZE, "train")

    def get_data(sess):
        x_batch, y_batch = inet.get_next_batch(sess)

        return x_batch, y_batch


ENCODER_WEIGHTS_PATH = 'vgg19_normalised.npz'
if data_set == "cifar10":
    # 'transform2.ckpt-147000'#./trans_pretrained/transform.ckpt'
    Decoder_Model = "./trans_pretrained/cifar10transform1.ckpt-574000"
elif data_set == "imagenet":
    # "./trans_pretrained/imagenetshallowtransform1.ckpt-104000"
    Decoder_Model = "./imagenetshallowtransform1.ckpt.mode2"
    DECAY_STEPS = 1.0
    adv_weight = 128
    ITER = 500
    CLIP_NORM_VALUE = 10.0

style_weight = 1

if data_set == "cifar10":
    raw_cifar = cifar10_input.CIFAR10Data("cifar10_data")

    def get_data(sess):
        x_batch, y_batch = raw_cifar.eval_data.get_next_batch(
            batch_size=BATCH_SIZE, multiple_passes=True)
        return x_batch, y_batch
elif data_set == "imagenet":
    inet = imagenet(BATCH_SIZE, "val")

    def get_data(sess):
        x_batch, y_batch = inet.get_next_batch(sess)

        return x_batch, y_batch


ENCODER_WEIGHTS_PATH = 'vgg19_normalised.npz'
if data_set == "cifar10":
    Decoder_Model = "./trans_pretrained/cifar10transform1.ckpt-574000"  #'transform2.ckpt-147000'#./trans_pretrained/transform.ckpt'
elif data_set == "imagenet":
    if decoder_name == "imagenet_shallowest":
        Decoder_Model = "./imagenetshallowesttransform1.ckpt.mode2"
    elif decoder_name == "imagenet_shallow":
        Decoder_Model = "./imagenetshallowtransform1.ckpt.mode2"  #"./trans_pretrained/imagenetshallowtransform1.ckpt-104000"