我的代码如下:
lr = 1e-3
window_length = 1
emb_size = 100
look_back = 10
expert_model = Sequential()
expert_model.add(Embedding(num_classes + 1, emb_size, input_length=look_back,mask_zero=True))
expert_model.add(LSTM(64, input_shape=(look_back,window_length)))
expert_model.add(Dense(num_classes, activation='softmax'))
我所要做的就是将大小为10的类的列表传递给嵌入层,然后传递给LSTM来预测下一类。也许该列表的长度不是10,所以我将mask_zero
属性设置为True
,并为嵌入层的词汇表添加了一个额外的值。这是正确的吗?
此外,我不确定window_length
是什么意思。这是否意味着要传递给嵌入的序列数?当我尝试运行此命令时,出现此错误:
ValueError: Error when checking input: expected embedding_13_input to have 2 dimensions, but got array with shape (1, 1, 0)
要预处理数据,我使用Processor
对象,因为此模型用于称为“ RecoGym”的OpenAI环境。该类如下:
class RecoProcessor(Processor):
def process_observation(self, observation):
if observation is None:
return np.array([], dtype='float32')
return np.array(observation, dtype='float32')
def process_state_batch(self, batch):
return np.array(batch).astype('float32')
def process_reward(self, reward):
return np.array(reward).astype('float32')
def process_demo_data(self, demo_data):
for step in demo_data:
step[0] = self.process_observation(step[0])
step[2] = self.process_reward(step[2])
return demo_data
请,我需要一些帮助。如果您只能给我一个有关此的教程,我将不胜感激。