2

I am trying to create a chatbot with Jupyter notebook and when I run the script I get this error;

WARNING:tensorflow:From C:\Users\ASUS\anaconda3\lib\site-packages\tensorflow\python\compat\v2_compat.py:96: 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

I don't know how to solve this issue. My code is:

import nltk
from nltk.stem.lancaster import LancasterStemmer
stemmer = LancasterStemmer()

import numpy
import tflearn
import tensorflow
import random
import json


with open("D:\intents.json") as file:
    data = json.load(file)



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)
Abdullah Ergun
  • 63
  • 1
  • 1
  • 8

3 Answers3

4

The warning usually comes when you use the older version of Tensrflow like 1.x or if you have migrated from Tensrflow 1.x to Tensorflow 2.x using automated script.

If you are using Tensorflow 1.x, you can consider upgrading to Tensorflow 2.x since it has lot of performance advantages compared to older version and will be stable for the long run.

In Tensorflow 2.x using tf.Variable creates a Resource variable as default with eager execution is enabled by default.

Coming to the warning tf.compat.v1.disable_resource_variables() is depreciated instead you can mention use_resource= False in tf.get_variable() which will be forced to true when eager excecution is enabled by default in Tensorflow 2.x.

0

As "Tech with Tim" mentioned in his video Python Chat Bot Tutorial - Chatbot with Deep Learning, he said:

Python 3.7 contains bug.

So just install Python 3.6 from the Official Python website.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
0

I found answer under different issue, here

Solution for TF 1.x:

tf.logging.set_verbosity(tf.logging.ERROR)

For TF 2.x:

tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

Ensure that this is placed before you import tensorflow in your script

Josie Koay
  • 735
  • 7
  • 8