Pickle TypeError: требуется объект, похожий на байты, а не str - PullRequest
0 голосов
/ 05 мая 2020

Вызов getVocab () дает мне TypeError: требуется объект, похожий на байты, а не str

def getVocab():
  file = open("../words/vocab")
  return pickle.load(file)

Файл словаря выглядит так

(dp0
S'slope'
p1
I516
sS'pointing'
p2
I3
sS'hats'
p3
I4
sS'people'
p4
I825
sS'yellow'
p5
I5

Трассировка приведено ниже

2020-05-05 21:46:52.986615: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187]      
Traceback (most recent call last):
  File "main.py", line 181, in <module>
    m = Main()
  File "main.py", line 22, in __init__
    self.texti = loadData.TextIterator(self.batchSize, self.seqLen)
  File "/home/ichimichi/Downloads/data-of-multimodal-sarcasm-detection-e428b1497dea29d7e39592ea1d266c1de44084f1/codes/loadData.py", line 25, in __init__
    self.word2id = self.getVocab()
  File "/home/ichimichi/Downloads/data-of-multimodal-sarcasm-detection-e428b1497dea29d7e39592ea1d266c1de44084f1/codes/loadData.py", line 48, in getVocab
    return pickle.load(file)
TypeError: a bytes-like object is required, not 'str'
...