tensorflow-gpu 2.2.0
Keras 2.3.1
import os
import keras
from keras.applications import VGG16
from keras import models
from keras import layers
from keras.preprocessing.image import ImageDataGenerator
from keras import optimizers
train_dir = 'E://pythonsave//mnist_data//picture//picture//train' #训练
#validation_dir = #验证
test_dir = 'E://pythonsave//mnist_data//picture//picture//test' #测试
conv_base = VGG16(weights='imagenet',
include_top=False,
input_shape=(150, 150,3))
model = models.Sequential()
model.add(conv_base)
model.add(layers.Flatten())
model.add(layers.Dense(256, activation='relu'))
model.add(layers.Dropout(0.5))
model.add(layers.Dense(units = 4, activation='softmax')) #“4”为分类数量ÿ