我正在尝试使用经过预训练的MobileNet进行迁移学习,但是当我第二次尝试运行相同的命令时遇到了问题
import tensorflow as tf
try:
del g1
except:
pass
g1 = tf.Graph()
with g1.as_default():
base_model = tf.keras.applications.MobileNetV2(input_shape=(160,160,3),
include_top=False,
weights='imagenet')
我第一次可以在jupyter中运行此单元,但是第二次尝试运行时
TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor("Placeholder_207:0", shape=(160,), dtype=float32) is not an element of this graph.
但是,我可以多次运行此单元格
base_model = tf.keras.applications.MobileNetV2(input_shape=(160,160,3),
include_top=False,
weights='imagenet')