ValueError:层激活_1的输入不是符号张量
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ValueError:层激活_1的输入不是符号张量相关的知识,希望对你有一定的参考价值。
from keras.layers import AveragePooling2D
from keras.models import Sequential
from keras.layers.normalization import BatchNormalization
from keras.layers.convolutional import Conv2D
from keras.layers.convolutional import MaxPooling2D
from keras.layers.core import Activation
from keras.layers.core import Flatten
from keras.layers.core import Dropout
from keras.layers.core import Dense
from keras import backend as K
class SmallerVGGNet:
@staticmethod
def build(width, height, depth, classes, finalAct="softmax"):
x = (height, width, depth)
output = -1
# CONV => RELU => POOL
x = (Conv2D(16, (3, 3), padding="same", input_shape=x))
x = (Activation("relu")(x))
x = (BatchNormalization(axis=output)(x))
x = (MaxPooling2D(pool_size=(3, 3))(x))
x = (Conv2D(32, (3, 3), padding="same")(x))
x = (Activation("relu")(x))
x = (BatchNormalization(axis=output)(x))
x = (MaxPooling2D(pool_size=(3, 3))(x))
x = (BatchNormalization(axis=output)(x))
# (CONV => RELU) * 2 => POOL
x = (Conv2D(64, (3, 3), padding="same")(x))
x = (Activation("relu")(x))
x = (BatchNormalization(axis=output)(x))
x = (Conv2D(64, (3, 3), padding="same")(x))
x = (Activation("relu")(x))
x = (BatchNormalization(axis=output)(x))
x = (AveragePooling2D(pool_size=(2, 2))(x))
# (CONV => RELU) * 2 => POOL
x = (Conv2D(128, (3, 3), padding="same")(x))
x = (Activation("relu")(x))
x = (BatchNormalization(axis=output)(x))
x = (Conv2D(128, (3, 3))(x))
x = (Activation("relu")(x))
x = (BatchNormalization(axis=output)(x))
x = (MaxPooling2D(pool_size=(2, 2))(x))
# first (and only) set of FC => RELU layers
x = (Flatten()(x))
x = (Dense(128)(x))
x = (Activation("relu")(x))
x = (BatchNormalization()(x))
x = (Dropout(0.5)(x))
# softmax classifier
x = (Dense(classes)(x))
x = (Activation(finalAct)(x))
x.summary()
# return the constructed network architecture
[enter image description here][2]
为什么这会在我运行代码时出现,为什么说层激活是用不是符号张量的输入来调用的。请帮助我解决此问题
ValueError:使用不是符号张量的输入来调用layer activation_1。收到的类型:。完整输入:[]。该层的所有输入都应为张量。
以上是关于ValueError:层激活_1的输入不是符号张量的主要内容,如果未能解决你的问题,请参考以下文章
ValueError:使用自定义回调绘制卷积层特征图时,函数模型的输出张量必须是 TensorFlow `Layer` 的输出
ValueError:无法为具有形状“(?,1)”的张量“Placeholder_1:0”提供形状(6165、5)的值
ValueError:Layer Discriminator 需要 1 个输入,但它接收到 2 个输入张量