image_gen_train = ImageDataGenerator(rescale = 1./255)
train_data_gen = image_gen_train.flow_from_directory(batch_size = batch_size,
directory = train_dir,
shuffle= True,
target_size = (IMG_SHAPE,IMG_SHAPE),
class_mode = 'binary')
image_generator_validation = ImageDataGenerator(rescale=1./255)
val_data_gen = image_generator_validation.flow_from_directory(batch_size=batch_size,
directory=validation_dir,
target_size=(IMG_SHAPE, IMG_SHAPE),
class_mode='binary')
image_gen_test = ImageDataGenerator(rescale=1./255)
test_data_gen = image_gen_test.flow_from_directory(batch_size=batch_size,
directory=test_dir,
target_size=(IMG_SHAPE, IMG_SHAPE),
class_mode='binary')
#preprocess data (train, test, validation), which includes, rescaling and shuffling.
pre_trained_model = tf.keras.applications.VGG16(input_shape=(224, 224, 3), include_top=False, weights="imagenet")
#Let’s download VGG-16 weights, by including the top layer parameter as false.
for layer in pre_trained_model.layers:
print(layer.name)
layer.trainable = False
#we need to freeze the training layers of VGG-16
我该如何解决这个错误?其中显示“文件”,第 2 行 打印(图层名称) ^ IndentationError:需要一个缩进块“