关于model.load的Tflearn问题

时间:2017-07-14 09:37:10

标签: python tensorflow tflearn

# restore all of our data structures
import pickle
import tflearn
import tensorflow as tf
import random
...
# load our saved model
model.load('./model.tflearn')

def clean_up_sentence(sentence):
    # tokenize the pattern
    sentence_words = nltk.word_tokenize(sentence)
    # stem each word

我的错误

$ python wrapper.py

Scipy not supported!
Traceback (most recent call last):
  File "wrapper.py", line 18, in <module>
    model.load('./model.tflearn')
NameError: name 'model' is not defined

任何帮助?

This is my directory

我的模型编写代码看起来像

model.fit(train_x, train_y, n_epoch=1000, batch_size=8, show_metric=True)
model.save('model.tflearn')

我正在使用tflearn开发一个聊天机器人,我训练了模型并保存了模型但是当我再次加载它然后它会抛出一个错误,同一目录中的python文件和模型也在同一个dir中。

1 个答案:

答案 0 :(得分:2)

net = tflearn.input_data(shape=[None, len(train_x[0])])
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, len(train_y[0]), activation='softmax')
net = tflearn.regression(net)
model = tflearn.DNN(net, tensorboard_dir='tflearn_logs')
# load our saved model
model.load('./model.tflearn')

我忘了提及变量模型,这使错误弹出。