def LM(batch_size, window_size=3, vocsize=20000, embed_dim=20, hidden_dim=30, nb_layers=1):
x = Input(batch_shape=(batch_size, None))
# mebedding
y = Embedding(vocsize+2, embed_dim, mask_zero=False)(x)
for i in range(nb_layers-1):
y = GCNN(hidden_dim, window_size=window_size,
name='gcnn{}'.format(i + 1))(y)
y = GCNN(hidden_dim, window_size=window_size,
name='gcnn{}'.format(nb_layers))(y)
y = TimeDistributed(Dense(vocsize+2, activation='softmax', name='dense{}'.format(nb_layers)))(y)
model = Model(inputs=x, outputs=y)
return model
评论列表
文章目录