Python (已解决)如何解决;运行时错误:试图使用关闭的会话;
修好了 使用上面的解决方案 我最近刚开始python编程,并决定承担一个聊天机器人培训模型项目。我一开始很成功,但是,我决定将main.py文件的名称改为另一个名称“oliveirachat.py”,并在json文件中添加了一些响应链接,以便对模型进行训练 这是以下代码的一部分:Python (已解决)如何解决;运行时错误:试图使用关闭的会话;,python,tensorflow,deep-learning,chatbot,Python,Tensorflow,Deep Learning,Chatbot,修好了 使用上面的解决方案 我最近刚开始python编程,并决定承担一个聊天机器人培训模型项目。我一开始很成功,但是,我决定将main.py文件的名称改为另一个名称“oliveirachat.py”,并在json文件中添加了一些响应链接,以便对模型进行训练 这是以下代码的一部分: with open("responselinks.json") as file: data = json.load(file) try: #when new links are adde
with open("responselinks.json") as file:
data = json.load(file)
try:
#when new links are added to responselinks, remove the hash for the x below
with open("data.pickle","rb") as f:
statements, labels, training, output = pickle.load(f)
except:
## Rest of the code here##
training = numpy.array(training)
output = numpy.array(output)
with open("data.pickle","wb") as f:
pickle.dump((statements, labels, training, output), f)
ops.reset_default_graph() #This is the model for the AI training
net = tflearn.input_data(shape=[None, len(training[0])]) #we start with an input data which has the length of our training data
net = tflearn.fully_connected(net, 8) #2 hidden layers of 8 neurons fully connected
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, len(output[0]), activation="softmax") #softmax function allows you to get probability for each neuron in this layer which will be our output for the network
net = tflearn.regression(net)
model = tflearn.DNN(net) #DNN type of neural network, uses the network we defined above
try:
model.load("model.tflearn")
except:
model.fit(training, output, n_epoch=1000, batch_size=8, show_metric=True) #epochs are the data being visualised, the hope is to expose the model to visualise the same data 1000 times
model.save("model.tflearn")
##Some more code here defining the last 2 functions for conversation here
此时问题开始出现:
我尝试删除文件夹中的pickle文件和一些其他数据,但是
很抱歉让这篇文章比它应该的要长一点。我是新来的,所以我没有包含其余的代码,而是只包含了我认为问题可能存在的部分,因为它第一次起作用