我真的很难理解你的问题。你的意思是说你的输入是一个 1000 维的特征向量,总共有 16 个,而你的网络输出,即目标,是四种可能的疾病之一?
如果是这种情况,那么您误解了 CNN 的输入形状,其批量大小未计算(您可能使用不同的批量大小,因此我们希望将此参数与模型解耦)。
根据您对 1000 维特征的理解,您希望在将其输入模型之前应用一些特征归一化。
from keras.layers import *
from keras.models import Model
# 1. define model parameters
# 1.1 dropout rate, you may want to use 0 first
dropout_rate = 0.2
# 1.2 mlp structure
fc_nodes = [128, 32, 8]
# activation, e.g. relu or tanh
activation = 'relu'
# 2. define model
# 2.1 define input
# note: batch_size=16 is NOT included in shape
feat_in = Input(shape=(1000,), name='feat_in')
# 2.2 define body
x = feat_in
for idx, nb_nodes in enumerate( fc_nodes ) :
x = Dense( nb_nodes, activation=activation, name='fc-{}'.format(idx) )(x)
if ( dropout_rate > 0 ) :
x = Dropout( dropout_rate, name='dropout-{}'.format(idx))(x)
# 2.3 define output
pred_out = Dense( 4, activation='softmax', name='pred_out')(x)
# 2.4 define model
model = Model( inputs=feat_in, outputs=pred_out, name='my_model')
# 3. display model architecture
print model.summary()
此模型将采用形状为 (batch_size, 1000) 的二维张量并预测形状为 (batch_size, 4) 的二维张量。
顺便说一句,Conv2D 应仅在您的输入类似于图像的情况下使用,这不是您的情况。