Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何获得渴望模式的中间输出_Python_Tensorflow_Eager - Fatal编程技术网

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.