Search code examples
pythontensorflowtflearn

Tflearn issue over model.load


# 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

my error

$ 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

any help ?

This is my directory

and my model write code looks like

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

I am developing a chatbot using tflearn, I trained the model and saved the model but when I load it again then it throws a error , both the python files in same directory and models are in same dir too..


Solution

  • 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')
    

    I forgot to mention the variable model and this made the error to pop out.