GT 145
Decapat
- Katılım
- 29 Temmuz 2021
- Mesajlar
- 723
- Çözümler
- 1
Arkadaşlar bugün sıkıntıdan ChatGPT'ye girdim. Normalde pek sık girmem neyse bir kod yazdırdım ama hata veriyor nasıl çözebilirim?
Hata:
ChatGPT'ye soramıyorum çok yoğun hata veriyor.
Python:
import torch
import torch.nn as nn
import torch.nn.functional as F
import random
bot_responses = ["Merhaba, nasıl yardımcı olabilirim?", "Sanırım anlamadım, tekrar edebilir misiniz?", "Bu konuda size yardımcı olabilirsem ne kadar iyi olur!", "Malesef bu konuda size yardımcı olamıyorum."]
class NeuralNet(nn.Module):
def __init__(self):
super(NeuralNet, self).__init__()
self.fc1 = nn.Linear(300, 256)
self.fc2 = nn.Linear(256, 128)
self.fc3 = nn.Linear(128, 64)
self.fc4 = nn.Linear(64, 32)
self.fc5 = nn.Linear(32, 1)
def forward(self, x):
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = F.relu(self.fc3(x))
x = F.relu(self.fc4(x))
x = torch.sigmoid(self.fc5(x))
return x
model = NeuralNet()
def chatbot_response(text):
input = torch.tensor(text_to_vector(text)).float().unsqueeze(0)
output = model(input)
index = output.data.cpu().numpy().argmax()
return bot_responses[index]
def text_to_vector(text):
# burada belirli bir metod kullanarak metin verilerinin vektörel bir
# forma dönüştürülmesi gerekir
return None
def run_chatbot():
while True:
user_input = input("You: ")
if user_input.lower() == "q":
break
bot_response = chatbot_response(user_input)
print("Bot: ", bot_response)
if __name__ == "__main__":
run_chatbot()
Hata:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 47, in <module>
File "<string>", line 43, in run_chatbot
File "<string>", line 28, in chatbot_response
RuntimeError: Could not infer dtype of NoneType
ChatGPT'ye soramıyorum çok yoğun hata veriyor.
Son düzenleme: