img_height,img_width = 32, 32
base_model = ResNet50(weights = 'imagenet', include_top = False, input_shape =(img_height,img_width,3))
x = base_model.output
x = GlobalAveragePooling2D()(x)
x = Dropout(0.7)(x)
predictions = Dense(num_classes, activation = 'softmax')(x)
model = Model(inputs = base_model.input, outputs = predictions)
model.compile(optimizer = Adam(), lr = 0.0001, loss = 'categorical_crossentropy', metrics = ['accuracy'])
model.fit(X_train, y_train, epochs = 20, batch_size = 128)
我正在尝试使用Resnet在CIFAR-10数据集上执行图像分类任务。我使用的是带有TensorFlow 2.5.0版的colab CPU
我在“model.fit”行中遇到此错误:
InvalidArgumentError: Node 'training/Adam/gradients/gradients/conv5_block3_3_bn/cond_grad/StatelessIf': Connecting to invalid output 3 of source node conv5_block3_3_bn/cond which has 3 outputs. Try using tf.compat.v1.experimental.output_all_intermediates(True).
我能够使用TF2.5在colab上执行代码而没有任何问题
输出:
相关问题 更多 >
编程相关推荐