【问题标题】:Layer was called with an input that isn't a symbolic tensor. [Keras]使用不是符号张量的输入调用图层。 [凯拉斯]
【发布时间】:2019-06-04 00:30:26
【问题描述】:

我在以下代码中遇到错误

flatten = Flatten()(drop_5)
aux_rand = Input(shape=(1,))
concat = Concatenate([flatten, aux_input])

fc1 = Dense(512, kernel_regularizer=regularizers.l2(weight_decay))(concat)

ValueError: Layer dense_1 被调用的输入不是 符号张量。接收类型:.完整输入:[]。所有输入到 层应该是张量。

(x_train, y_train), (x_test, y_test) = cifar10.load_data()
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')

aux_rand = np.random.rand(y_train.shape[0])
model_inst = cifar10vgg()
x_train_input = Input(shape=(32,32,3))
aux_input = Input(shape=(1,))
model = Model(inputs=[x_train_input, aux_input], output=model_inst.build_model())
model.fit(x=[x_train, aux_rand], y=y_train, batch_size=batch_size, steps_per_epoch=x_train.shape[0] // batch_size,
                epochs=maxepoches, validation_data=(x_test, y_test),
                callbacks=[reduce_lr, tensorboard], verbose=2)

model_inst.build_model() 返回模型最后一层的输出 (Activation('softmax')(fc2))

【问题讨论】:

    标签: tensorflow keras conv-neural-network


    【解决方案1】:

    发生错误是因为concat 不是张量。层keras.layers.Concatenate 应按如下方式调用:

    concat = Concatenate()([flatten, aux_input])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-29
      • 2019-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-30
      • 1970-01-01
      相关资源
      最近更新 更多