无效的参数:您必须使用dtype float和形状[?,32,32,3]

我遇到了以下错误

  

InvalidArgumentError:找到2个根本错误。 (0)无效的参数:   您必须使用以下参数输入占位符张量'vgg16_input_4'的值   dtype浮点数和形状[?,32,32,3] [[{{node vgg16_input_4}}]]
  [[dense_6 / Softmax / _1775]](1)无效的参数:您必须输入   dtype float和占位符张量'vgg16_input_4'的值   形状[?,32,3] [[{{node vgg16_input_4}}]] 0成功   操作。忽略0个派生错误。

和以下代码

def show_result(n):

    samples = []
    for i in range(n):
        original_img = x_test[i]
        print('original_img->',original_img.shape)

        img_array = np.expand_dims(original_img,0)
        #img_array = original_img


        print('img_arrray->',img_array.shape)
        #tf.image.convert_image_dtype(img_array,dtype=tf.float16,saturate=False)

        get_output = K.function([model.layers[0].input],[model.layers[-3].output,model.layers[-1].output])
        [conv_outputs,predictions] = get_output([img_array])

        conv_outputs = conv_outputs[0,:,:]
        class_weights = model.layers[-1].get_weights()[0]

        cam = np.zeros(dtype = np.float32,shape = conv_outputs.shape[0:2])

图像的形状是

  

original_img->(32、32、3)img_arrray->(1、32、32、3)

model = models.Sequential()

base_model = VGG16(include_top = False,input_shape=(32,3))
base_model.layers.pop()
model.add(base_model)
model.add(layers.ZeroPadding2D(padding=(1,1)))
model.add(layers.Conv2D(filters=1024,kernel_size=(3,3),activation='relu'))
model.add(layers.GlobalAveragePooling2D())
model.add(layers.Dense(10,activation='softmax'))
dqsj09021013 回答:无效的参数:您必须使用dtype float和形状[?,32,32,3]

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3126262.html

大家都在问