fgsm_adv_training.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:AdversarialMachineLearning_COMP551 作者: arunrawlani 项目源码 文件源码
def vgg19(input_shape):
    base_model = VGG19(weights='imagenet', include_top=False, input_shape=input_shape)

    # add a global spatial average pooling layer
    x = base_model.output
    x = MaxPooling2D()(x)
    # let's add a fully-connected layer
    x = Flatten()(x)
    x = Dense(512, activation='relu')(x)
    x = Dropout(0.5)(x)
    #x = Dense(512, activation='relu')(x)
    #x = Dropout(0.5)(x)
    # and a logistic layer -- let's say we have 200 classes
    predictions = Dense(10, activation='softmax')(x)

    # this is the model we will train
    model = Model(input=base_model.input, output=predictions)

    # first: train only the top layers (which were randomly initialized)
    # i.e. freeze all convolutional InceptionV3 layers
    for layer in base_model.layers:
        layer.trainable = False

    # compile the model (should be done *after* setting layers to non-trainable)
    # model.compile(optimizer=Adam(lr=0.0001), loss='categorical_crossentropy', metrics=['accuracy'])

    return model
    #return predictions
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号