This is the code I am using
import nltk
from nltk.stem.lancaster import LancasterStemmer
stemmer = LancasterStemmer()
import pickle
import numpy
import tflearn
import tensorflow
import random
import json
with open(“intents.json”) as file:
data = json.load(file)
try:
with open(“data.pickle”, “rb”) as f:
words, labels, training, output = pickle.load(f)
except:
words =
labels =
docs_x =
docs_y =
for intent in data["intents"]:
for pattern in intent["patterns"]:
wrds = nltk.word_tokenize(pattern)
words.extend(wrds)
docs_x.append(wrds)
docs_y.append(intent["tag"])
if intent["tag"] not in labels:
labels.append(intent["tag"])
words = [stemmer.stem(w.lower()) for w in words if w != "?"]
words = sorted(list(set(words)))
labels = sorted(labels)
training = []
output = []
out_empty = [0 for _ in range(len(labels))]
for x, doc in enumerate(docs_x):
bag = []
wrds = [stemmer.stem(w.lower()) for w in doc]
for w in words:
if w in wrds:
bag.append(1)
else:
bag.append(0)
output_row = out_empty[:]
output_row[labels.index(docs_y[x])] = 1
training.append(bag)
output.append(output_row)
training = numpy.array(training)
output = numpy.array(output)
with open("data.pickle", "wb") as f:
pickle.dump((words, labels, training, output), f)
“”“tensorflow.compat.v1.reset_default_graph()”“”
net = tflearn.input_data(shape=[None, len(training[0])])
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, len(output[0]), activation=“softmax”)
net = tflearn.regression(net)
model = tflearn.DNN(net)
try:
model.load(“model.tflearn”)
except:
model.fit(training, output, n_epoch=1000, batch_size=8, show_metric=True)
model.save(“model.tflearn”)
And this is the error I am getting:
“C:\Users\Convertible Tablet\anaconda3\envs\chatbot\python.exe” “C:\Users\Convertible Tablet\PycharmProjects\chatbot\main.py”
2023-04-20 20:40:04.767682: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘cudart64_110.dll’; dlerror: cudart64_110.dll not found
2023-04-20 20:40:04.768847: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
WARNING:tensorflow:From C:\Users\Convertible Tablet\anaconda3\envs\chatbot\lib\site-packages\tensorflow\python\compat\v2_compat.py:101: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
WARNING:tensorflow:From C:\Users\Convertible Tablet\anaconda3\envs\chatbot\lib\site-packages\tflearn\initializations.py:165: calling TruncatedNormal.init (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
2023-04-20 20:40:08.656565: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library ‘nvcuda.dll’; dlerror: nvcuda.dll not found
2023-04-20 20:40:08.657278: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)
2023-04-20 20:40:08.670138: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: DESKTOP-KOCSDHE
2023-04-20 20:40:08.670475: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: DESKTOP-KOCSDHE
2023-04-20 20:40:08.673838: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Process finished with exit code 0