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 如何解决意外发现类型为“”的实例的问题<;类别';keras.engine.keras_tensor.KerasTensor传感器&x27>;`。应为符号张量实例。?_Python_Tensorflow_Keras_Resnet - Fatal编程技术网

Python 如何解决意外发现类型为“”的实例的问题<;类别';keras.engine.keras_tensor.KerasTensor传感器&x27>;`。应为符号张量实例。?

Python 如何解决意外发现类型为“”的实例的问题<;类别';keras.engine.keras_tensor.KerasTensor传感器&x27>;`。应为符号张量实例。?,python,tensorflow,keras,resnet,Python,Tensorflow,Keras,Resnet,我在Keras中实现ResNet 50时出错,我正在设置输入张量的初始化值。我目前正以这种方式使用此模型,6天前我得到了ValueError:意外地发现了类型为的实例。应为符号张量实例。我尝试使用keras_占位符,但最后一层开始给我带来更多麻烦。我以为这是关于Keras版本的,但我安装了其他版本,他们给我的错误我没有。有人知道我能做什么吗 image_input = Input(shape=(width_shape, height_shape, 3)) m_Resnet50 = ResNet5

我在Keras中实现ResNet 50时出错,我正在设置输入张量的初始化值。我目前正以这种方式使用此模型,6天前我得到了ValueError:意外地发现了类型为
的实例。应为符号张量实例。我尝试使用keras_占位符,但最后一层开始给我带来更多麻烦。我以为这是关于Keras版本的,但我安装了其他版本,他们给我的错误我没有。有人知道我能做什么吗

image_input = Input(shape=(width_shape, height_shape, 3))
m_Resnet50 = ResNet50(input_tensor=image_input, include_top=False,weights='imagenet')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-49ab3019852b> in <module>()
  1 image_input = Input(shape=(width_shape, height_shape, 3))
 ----> 2 m_Resnet50 = ResNet50(input_tensor=image_input, include_top=False,weights='imagenet')
  3 
  4 m_Resnet50.summary()


 /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/backend.py in is_keras_tensor(x)
 1276                      keras_tensor.KerasTensor)):
 1277     raise ValueError('Unexpectedly found an instance of type `' + str(type(x)) +
-> 1278                      '`. Expected a symbolic tensor instance.')
 1279   if ops.executing_eagerly_outside_functions():
 1280     return isinstance(x, keras_tensor.KerasTensor)
image\u输入=输入(形状=(宽度\u形状,高度\u形状,3))
m_Resnet50=Resnet50(输入_tensor=image_输入,包括_top=False,weights='imagenet')
---------------------------------------------------------------------------
ValueError回溯(最近一次调用上次)
在()
1图像\输入=输入(形状=(宽度\形状,高度\形状,3))
---->2 m\u Resnet50=Resnet50(输入\u张量=图像\u输入,包括\u top=False,权重='imagenet')
3.
4 m_Resnet50.摘要()
/is_keras_tensor(x)中的usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/backend.py
1276 keras_张量,KerasTensor传感器):
1277 raise VALUETERROR('意外地找到了类型为''+str(类型为(x))的实例)+
->1278'`。应为符号张量实例。“)
1279如果操作。在函数()之外急切地执行函数():
1280返回信号持续时间(x,keras_张量KerasTensor.KerasTensor)

ValueError:意外发现类型为
的实例。需要一个符号张量实例。

我能够复制您的问题,如下所示

import tensorflow as tf
import keras

from tensorflow.keras.applications import ResNet50
from keras import layers, Model, Input

width_shape = 224
height_shape = 224

image_input = Input(shape=(width_shape, height_shape, 3))
m_Resnet50 = ResNet50(input_tensor=image_input, include_top=False,weights='imagenet')
m_Resnet50.summary()
import tensorflow as tf
print(tf.__version__)

from tensorflow.keras.applications import ResNet50
from tensorflow.keras import layers, Model, Input

width_shape = 224
height_shape = 224

image_input = Input(shape=(width_shape, height_shape, 3))
m_Resnet50 = ResNet50(input_tensor=image_input, include_top=False,weights='imagenet')
#m_Resnet50.summary()
输出:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-4d2f17c32b79> in <module>()
      9 
     10 image_input = Input(shape=(width_shape, height_shape, 3))
---> 11 m_Resnet50 = ResNet50(input_tensor=image_input, include_top=False,weights='imagenet')
     12 m_Resnet50.summary()
     13 

2 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/backend.py in is_keras_tensor(x)
   1276                      keras_tensor.KerasTensor)):
   1277     raise ValueError('Unexpectedly found an instance of type `' + str(type(x)) +
-> 1278                      '`. Expected a symbolic tensor instance.')
   1279   if ops.executing_eagerly_outside_functions():
   1280     return isinstance(x, keras_tensor.KerasTensor)

ValueError: Unexpectedly found an instance of type `<class 'keras.engine.keras_tensor.KerasTensor'>`. Expected a symbolic tensor instance.

您正在混合keras和tf.keras,它们是不同的库,不能一起使用。