#1164·tflearn

ValueError: Cannot feed value of shape (61,) for Tensor 'InputData/X:0', which has shape '(?, 61)'

Author: monibakaCreated Apr 5, 2021Updated Jan 9, 2022

HELP needed. How can I fix this error?

` def bag_of_words(s, words): bag = [0 for _ in range(len(words))]

s_words = nltk.word_tokenize(s)
s_words = [stemmer.stem(word.lower()) for word in s_words]

for se in s_words:
    for i, w in enumerate(words):
        if w == se:
            bag[i] = 1

return np.array(bag)

def chat(): print("Start talking with the bot! (type quit to stop)") while True: inp = input("You: ") if inp.lower() == "quit": break

    result = model.predict([bag_of_words(inp, words)])[0]
    result_index = np.argmax(result)
    tag = labels[result_index]

    if result[result_index] > 0.7:
        for tg in data["intents"]:
            if tg['tag'] == tag:
                responses = tg['responses']
        print(random.choice(responses))

    else:
        print("I didnt get that. Can you explain or try again.")

chat()`

And when I run it I get: Start talking with the bot! (type quit to stop)

You: j Traceback (most recent call last):

File "", line 22, in chat()

File "", line 8, in chat result = model.predict([bag_of_words(inp, words)])

File "C:\Users\monik\anaconda3\lib\site-packages\tflearn\models\dnn.py", line 251, in predict return self.predictor.predict(feed_dict)

File "C:\Users\monik\anaconda3\lib\site-packages\tflearn\helpers\evaluator.py", line 69, in predict return self.session.run(self.tensors[0], feed_dict=feed_dict)

File "C:\Users\monik\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\client\session.py", line 967, in run result = self._run(None, fetches, feed_dict, options_ptr,

File "C:\Users\monik\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\client\session.py", line 1164, in _run raise ValueError(

ValueError: Cannot feed value of shape (61,) for Tensor 'InputData/X:0', which has shape '(?, 61)'

I tried to reshape it, but still it doesn't work