使用的库列表

tensorflow 2.7.0
keras 2.7.0

问题1:cannot import name ‘VGG16’ from ‘keras.applications’

改为from tensorflow.keras.applications import VGG16即可
输出结果:

Downloading data from https://storage.googleapis.com/tensorflow/keras-applications/vgg16/vgg16_weights_tf_dim_ordering_tf_kernels_notop.h5
58892288/58889256 [==============================] - 50s 1us/step
58900480/58889256 [==============================] - 50s 1us/step

问题2:module ‘keras.optimizers’ has no attribute ‘SGD’

改为from tensorflow import optimizers即可

问题3:KeyError: ‘acc’

发生错误的代码:acc = history.history['acc']
改为acc = history.history['accuracy']即可

问题4:UserWarning: The ‘lr’ argument is deprecated, use ‘learning_rate’ instead

发生错误的代码: model.compile(……,optimizer=optimizers.RMSprop(lr=1e-5),……
改为model.compile(……,optimizer=optimizers.RMSprop(learning_rate=1e-5),……]即可

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐