gpt4 book ai didi

tensorflow - 使用不是符号张量的输入调用层。 [凯拉斯]

转载 作者:行者123 更新时间:2023-12-03 19:31:25 28 4
gpt4 key购买 nike

我在以下代码中收到错误

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 was called with an input that isn't a symbolic tensor. Received type: . Full input: []. All inputs to the layer should be tensors.


(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) )

最佳答案

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

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

关于tensorflow - 使用不是符号张量的输入调用层。 [凯拉斯],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54106631/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com