Python 如何获得渴望模式的中间输出
我建立了一个迁移学习模型,并试图获得中间输出。为了得到模型的中间输出,我遵循其中一个建议,如下所示:Python 如何获得渴望模式的中间输出,python,tensorflow,eager,Python,Tensorflow,Eager,我建立了一个迁移学习模型,并试图获得中间输出。为了得到模型的中间输出,我遵循其中一个建议,如下所示: import tensorflow as tf from tensorflow.keras import backend as K tf.enable_eager_execution() base_conv = tf.keras.applications.MobileNetV2(input_shape= None, alpha=1.0, depth_multipli
import tensorflow as tf
from tensorflow.keras import backend as K
tf.enable_eager_execution()
base_conv = tf.keras.applications.MobileNetV2(input_shape= None,
alpha=1.0, depth_multiplier=1, \
include_top=True, weights='imagenet', input_tensor=None, \
pooling=None, classes=1000)
model = tf.keras.models.Sequential()
model.add(base_conv)
model.add(tf.keras.layers.Dense(512, activation='relu'))
model.add(tf.keras.layers.Dense(5, activation='softmax'))
# with a Sequential model
get_layer_output = K.function([model.layers[0].input],
[model.layers[0].get_layer('Conv_1').output])
#x is the input image
layer_output = get_layer_output([x])
但后来我犯了一个错误:
AttributeError: Tensor.name is meaningless when eager execution is enabled.