【发布时间】:2020-06-19 20:35:43
【问题描述】:
我正在创建一个大小为 80 的 CNN,用于第一个隐藏层,160 用于其余的转换层,128 用于最后一个隐藏层。但是我一直遇到错误消息,我真的不知道这意味着什么。输入数据形状是 (80, 80, 1),这是我输入神经网络的数据。
这是创建 CNN 的代码:
if start_model is not None:
model = load_model(start_model)
else:
def res_net_block(input_layers, conv_size, hm_filters, hm_strides):
x = Conv2D(conv_size, kernel_size=hm_filters, strides=hm_strides, activation="relu", padding="same")(input_layers)
x = BatchNormalization()(x)
x = Conv2D(conv_size, kernel_size=hm_filters, strides=hm_strides, activation=None, padding="same")(x)
x = Add()([x, input_layers]) # Creates resnet block
x = Activation("relu")(x)
return x
input = keras.Input(i_shape)
x = Conv2D(80, kernel_size=8, strides=4, activation="relu")(input)
x = BatchNormalization()(x)
for i in range(3):
x = res_net_block(x, 160, 4, 2)
x = Conv2D(160, kernel_size=4, strides=2, activation="relu")(x)
x = BatchNormalization()(x)
x = Flatten(input_shape=(np.prod(window_size), 1, 1))(x)
x = Dense(128, activation="relu")(x)
output = Dense(action_space_size, activation="linear")(x)
model = keras.Model(input, output)
model.compile(optimizer=Adam(lr=0.01), loss="mse", metrics=["accuracy"])
顺便说一句,错误消息位于代码中的x = Add()([x, input_layers])
【问题讨论】:
标签: python tensorflow machine-learning artificial-intelligence conv-neural-network