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()
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
Hatayı atın hocam direkt gptye.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?
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
Çok yoğun hata veriyor.Hatayı atın hocam direkt gptye.
Kodu ChatGPT'nin yazdığına emin misiniz?
O input isimli değişken hatasını 3 yaşındaki çocuk bile yapmaz.
Kodu ChatGPT'nin yazdığına emin misiniz?
O input isimli değişken hatasını 3 yaşındaki çocuk bile yapmaz.
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
# Örnek olarak, verilen metnin uzunluğunun 300 boyutlu bir vektör olarak
# dönüştürülmesi
return [len(text) for i in range(300)]
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()
Teşekkürler.Bende girilmiyor ChatGPT'ye ondan çözemedim.ChatGPT'ye sordum şunları söyledi;
Eki Görüntüle 1660564
Ve hatayı giderip kodu atmasını istediğimde bunu attı.
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 # Örnek olarak, verilen metnin uzunluğunun 300 boyutlu bir vektör olarak # dönüştürülmesi return [len(text) for i in range(300)] 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()
Ve bunu yazdı;
Eki Görüntüle 1660565
Benim bildiğim paylaştığınız hata mesajının hemen üstünde hatanın yerde olduğunu söylüyor olmalı.
Daha önce keyword adına değişken atlayıp çalıştırmayı denemediğim için nasıl bir sonuç alınacağını bilmiyorum.
Pek çok şeye. Kodlamanın kendisinden ziyade modele ve modelin eğitilebileceği verinin hem sayısına hem de kalitesine bağlı. Rastgele insanların böğürdüğü 1 milyon saatlik verin olsa düzgün bir speech modeli eğitemezsin mesela.Hocam hazır buradayken şunu sorsam. Yapay zekanın gelişmişliği veri bolluğunamı bağlı yoksa kodlamaya falan mı?