qq_31247017
孔橙
2019-02-15 23:52

keras模型输出层希望输出的shape是(None,1)但我写的模型输出一个三维的shape(None,10,1)

  • tensorflow
  • 深度学习

图片说明

图片说明

### model
taxi_id = Input(shape=(10, 1))
mask_1 = Masking(mask_value=0)(taxi_id)
embedding_1 = Embedding(15000, 14, mask_zero=True)(mask_1)
time_id = Input(shape=(10, 1))
mask_2 = Masking(mask_value=0)(time_id)
embedding_2 = Embedding(7, 4, mask_zero=True)(mask_2)
busy = Input(shape=(10, 1))
mask_3 = Masking(mask_value=0)(busy)
embedding_3 = Embedding(2, 2, mask_zero=True)(mask_3)
concatenate_1 = Concatenate(axis=3)([embedding_1,embedding_2,embedding_3])
concatenate_1 = Lambda(dim_squeeze)(concatenate_1)
num_input = Input(shape=(10, 3))
mask_4 = Masking(mask_value=0, input_shape=())(num_input)
concatenate_2 = Concatenate(axis=2)([concatenate_1, mask_4])
blstm_1 = Bidirectional(LSTM(64,  activation='tanh', return_sequences=True, dropout=0.2, recurrent_dropout=0.2))(concatenate_2)
blstm_2 = Bidirectional(LSTM(128,  activation='tanh', return_sequences=True, dropout=0.2, recurrent_dropout=0.2))(blstm_1)
blstm_3 = Bidirectional(LSTM(64,  activation='tanh', return_sequences=True, dropout=0.2, recurrent_dropout=0.2))(blstm_2)
dense_1 = Dense(128)(blstm_3)
leaky_relu_1 = advanced_activations.LeakyReLU(alpha=0.3)(dense_1)
dense_2 = Dense(128)(leaky_relu_1)
leaky_relu_2 = advanced_activations.LeakyReLU(alpha=0.3)(dense_2)
dense_3 = Dense(128)(leaky_relu_2)
leaky_relu_3 = advanced_activations.LeakyReLU(alpha=0.3)(dense_3)
dense_4 = Dense(128)(leaky_relu_3)
leaky_relu_4 = advanced_activations.LeakyReLU(alpha=0.3)(dense_4)
add_1 = add([leaky_relu_1, leaky_relu_2, leaky_relu_3, leaky_relu_4])
dense_5 = Dense(1)(add_1)
model = Model([taxi_id, time_id, busy, num_input], dense_5)

求教大佬该怎么写能把输出维度降下来

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换