匿名
匿名 發問於 電腦與網際網路程式設計 · 4 星期前

python 載入pkl的問題?

AttributeError Traceback (most recent call last)

<ipython-input-8-cd6baf818950> in <module>

----> 1 critic = joblib.load('C:/Users/bigje/Desktop/Critic(R10).pkl').eval()

D:\Anaconda\python\lib\site-packages\joblib\numpy_pickle.py in load(filename, mmap_mode)

    583 return load_compatibility(fobj)

    584

--> 585 obj = _unpickle(fobj, filename, mmap_mode)

    586 return obj

D:\Anaconda\python\lib\site-packages\joblib\numpy_pickle.py in _unpickle(fobj, filename, mmap_mode)

    502 obj = None

    503 try:

--> 504 obj = unpickler.load()

    505 if unpickler.compat_mode:

    506 warnings.warn("The file '%s' has been generated with a "

D:\Anaconda\python\lib\pickle.py in load(self)

   1208 raise EOFError

   1209 assert isinstance(key, bytes_types)

-> 1210 dispatch[key[0]](self)

   1211 except _Stop as stopinst:

   1212 return stopinst.value

D:\Anaconda\python\lib\pickle.py in load_stack_global(self)

   1533 if type(name) is not str or type(module) is not str:

   1534 raise UnpicklingError("STACK_GLOBAL requires str")

-> 1535 self.append(self.find_class(module, name))

   1536 dispatch[STACK_GLOBAL[0]] = load_stack_global

   1537

D:\Anaconda\python\lib\pickle.py in find_class(self, module, name)

   1577 __import__(module, level=0)

   1578 if self.proto >= 4:

-> 1579 return _getattribute(sys.modules[module], name)[0]

   1580 else:

   1581 return getattr(sys.modules[module], name)

更新:

D:\Anaconda\python\lib\pickle.py in _getattribute(obj, name)

    329 obj = getattr(obj, subpath)

    330 except AttributeError:

--> 331 raise AttributeError("Can't get attribute {!r} on {!r}"

    332 .format(name, obj)) from None

    333 return obj, parent

AttributeError: Can't get attribute 'Critic' on <module '__main__'>

這樣該怎麼解決呢??請求各位高手們~~

尚未解答。
成為第一個解答此問題的人。