使用FGSM的对抗示例,在训练对抗样本时(https://tensorflow.google.cn/tutorials/generative/adversarial_fgsm),遇到以下问题
pretrained_model = tf.keras.applications.MobileNetV2(include_top=True,weights='imagenet')
pretrained_model.trainable = False
# ImageNet labels
decode_predictions = tf.keras.applications.mobilenet_v2.decode_predictions
第一次没有下载成功,第二次报错
OSError: Unable to open file (truncated file: eof = 40960, sblock->base_addr = 0, stored_eof = 14536120)
原因分析:
由于网络中断,导致keras加载MobileNetV2模型权重失败
解决办法:删除下载文件,重新下载
Windows-weights路径: C:\Users\用户名\.keras\models
Linux-weights路径:.keras/models/ (注意: linux中带点号的文件都被隐藏了,需要查看hidden文件才能显示)
参考:https://www.cnblogs.com/eniac1946/p/7808439.html
MobileNetV2下载地址:
https://github.com/JonathanCMitchell/mobilenet_v2_keras/releases/download/v1.1/mobilenet_v2_weights_tf_dim_ordering_tf_kernels_1.0_224.h5
百度云下载链接:
链接:https://pan.baidu.com/s/1TdkKLdkZCTFsy9cz3V0eLg
提取码:nmmz