Keras嵌入层与LSTM
我原来的模型是:Keras嵌入层与LSTM,keras,lstm,recurrent-neural-network,Keras,Lstm,Recurrent Neural Network,我原来的模型是: input = Input(shape=(1, 6)) # 1 time step, 6 features LSTM_layer = LSTM(self.lstm_units, return_sequences=False, return_state=True) lstm_output, out_h, out_c = LSTM_layer(embedded, initial_state=[h, c]) 输入是一个单热向量,例如[0,1,0,0,0,0] 现在我已经读到,最好将
input = Input(shape=(1, 6)) # 1 time step, 6 features
LSTM_layer = LSTM(self.lstm_units, return_sequences=False, return_state=True)
lstm_output, out_h, out_c = LSTM_layer(embedded, initial_state=[h, c])
输入是一个单热向量,例如[0,1,0,0,0,0]现在我已经读到,最好将输入嵌入到LSTM,所以模型现在看起来像
input = Input(shape=(6,))
embedded = Embedding(6, 2, input_length=6)(input)
LSTM_layer = LSTM(self.lstm_units, return_sequences=False, return_state=True)
lstm_output, out_h, out_c = LSTM_layer(embedded, initial_state=[h, c])
虽然这是可行的,但我的问题是,嵌入层的输出现在是(?,6,2)。这是LSTM层眼中的6个时间步和2个特征。这是实现这种方法的正确方法吗?你能解释一下你想做什么吗?为什么要嵌入输入?@Digital Thinking我正在尝试实现ENAS()。虽然输入的维度很低,不足以证明使用嵌入层是合理的,但他们似乎还是使用了它。另外,知道如何解决这个问题也很好。