我是 Tensorflow 2 的新手,我想在 keras/tensorflow 中训练多输入神经网络。这是我的示例代码:
First_inputs = Input(shape=(2000, ),name="first")
Second_inputs = Input(shape=(4, ),name="second")
embedding_layer = Embedding(3,3, input_length=2000,)(First_inputs)
flatten = Flatten()(embedding_layer)
first_dense = Dense(neuronCount,kernel_initializer=initializer, )(flatten)
merge = concatenate([first_dense, Second_inputs])
drop = Dropout(dropout)(merge)
output = Dense(1, )(drop)
model = Model(inputs=[First_inputs, Second_inputs], outputs=output)
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.1,shuffle=True, random_state=42)
First_inputs =x_train[:,0:2000]
Second_inputs =x_train[:,2000:2004]
model.fit(([First_inputs, Second_inputs], y_train),validation_data=([First_inputs, Second_inputs], y_train),verbose=1,epochs=100,steps_per_epoch=209)
但是,我收到此错误:
ValueError: No gradients provided for any variable: ['embedding/embeddings:0', 'dense/kernel:0', 'dense/bias:0', 'dense_1/kernel:0'].
有人知道问题是什么吗?谢谢!
鸿蒙传说
相关分类