我正在尝试构建一个小型LSTM,可以通过在现有的Python代码上进行训练来学习编写代码(即使是垃圾代码)。我将几千行代码连接在一个文件中,跨越数百个文件,每个文件都<eos>以“序列结束”结尾。
例如,我的训练文件如下所示:
setup(name='Keras',
...
],
packages=find_packages())
<eos>
import pyux
...
with open('api.json', 'w') as f:
json.dump(sign, f)
<eos>
Run Code Online (Sandbox Code Playgroud)
我正在使用以下单词创建令牌:
file = open(self.textfile, 'r')
filecontents = file.read()
file.close()
filecontents = filecontents.replace("\n\n", "\n")
filecontents = filecontents.replace('\n', ' \n ')
filecontents = filecontents.replace(' ', ' \t ')
text_in_words = [w for w in filecontents.split(' ') if w != '']
self._words = set(text_in_words)
STEP = 1
self._codelines = []
self._next_words = []
for i in range(0, len(text_in_words) - self.seq_length, STEP):
self._codelines.append(text_in_words[i: i …Run Code Online (Sandbox Code Playgroud)