TypeError Traceback (most recent call last)
in
3 import joblib
4
----> 5 joblib.dump(model1, “model1.m”)
6
G:\anaconda3\envs\imooc_ai\lib\site-packages\joblib\numpy_pickle.py in dump(value, filename, compress, protocol, cache_size)
478 elif is_filename:
479 with open(filename, ‘wb’) as f:
–> 480 NumpyPickler(f, protocol=protocol).dump(value)
481 else:
482 NumpyPickler(filename, protocol=protocol).dump(value)
G:\anaconda3\envs\imooc_ai\lib\pickle.py in dump(self, obj)
485 if self.proto >= 4:
486 self.framer.start_framing()
–> 487 self.save(obj)
488 self.write(STOP)
489 self.framer.end_framing()
G:\anaconda3\envs\imooc_ai\lib\site-packages\joblib\numpy_pickle.py in save(self, obj)
280 return
281
–> 282 return Pickler.save(self, obj)
283
284
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save(self, obj, save_persistent_id)
601
602 # Save the reduce() output and finally memoize the object
–> 603 self.save_reduce(obj=obj, *rv)
604
605 def persistent_id(self, obj):
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save_reduce(self, func, args, state, listitems, dictitems, state_setter, obj)
715 if state is not None:
716 if state_setter is None:
–> 717 save(state)
718 write(BUILD)
719 else:
G:\anaconda3\envs\imooc_ai\lib\site-packages\joblib\numpy_pickle.py in save(self, obj)
280 return
281
–> 282 return Pickler.save(self, obj)
283
284
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save(self, obj, save_persistent_id)
558 f = self.dispatch.get(t)
559 if f is not None:
–> 560 f(self, obj) # Call unbound method with explicit self
561 return
562
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save_dict(self, obj)
969
970 self.memoize(obj)
–> 971 self._batch_setitems(obj.items())
972
973 dispatch[dict] = save_dict
G:\anaconda3\envs\imooc_ai\lib\pickle.py in _batch_setitems(self, items)
995 for k, v in tmp:
996 save(k)
–> 997 save(v)
998 write(SETITEMS)
999 elif n:
G:\anaconda3\envs\imooc_ai\lib\site-packages\joblib\numpy_pickle.py in save(self, obj)
280 return
281
–> 282 return Pickler.save(self, obj)
283
284
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save(self, obj, save_persistent_id)
601
602 # Save the reduce() output and finally memoize the object
–> 603 self.save_reduce(obj=obj, *rv)
604
605 def persistent_id(self, obj):
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save_reduce(self, func, args, state, listitems, dictitems, state_setter, obj)
715 if state is not None:
716 if state_setter is None:
–> 717 save(state)
718 write(BUILD)
719 else:
G:\anaconda3\envs\imooc_ai\lib\site-packages\joblib\numpy_pickle.py in save(self, obj)
280 return
281
–> 282 return Pickler.save(self, obj)
283
284
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save(self, obj, save_persistent_id)
558 f = self.dispatch.get(t)
559 if f is not None:
–> 560 f(self, obj) # Call unbound method with explicit self
561 return
562
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save_dict(self, obj)
969
970 self.memoize(obj)
–> 971 self._batch_setitems(obj.items())
972
973 dispatch[dict] = save_dict
G:\anaconda3\envs\imooc_ai\lib\pickle.py in _batch_setitems(self, items)
995 for k, v in tmp:
996 save(k)
–> 997 save(v)
998 write(SETITEMS)
999 elif n:
G:\anaconda3\envs\imooc_ai\lib\site-packages\joblib\numpy_pickle.py in save(self, obj)
280 return
281
–> 282 return Pickler.save(self, obj)
283
284
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save(self, obj, save_persistent_id)
558 f = self.dispatch.get(t)
559 if f is not None:
–> 560 f(self, obj) # Call unbound method with explicit self
561 return
562
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save_dict(self, obj)
969
970 self.memoize(obj)
–> 971 self._batch_setitems(obj.items())
972
973 dispatch[dict] = save_dict
G:\anaconda3\envs\imooc_ai\lib\pickle.py in _batch_setitems(self, items)
994 write(MARK)
995 for k, v in tmp:
–> 996 save(k)
997 save(v)
998 write(SETITEMS)
G:\anaconda3\envs\imooc_ai\lib\site-packages\joblib\numpy_pickle.py in save(self, obj)
280 return
281
–> 282 return Pickler.save(self, obj)
283
284
G:\anaconda3\envs\imooc_ai\lib\pickle.py in save(self, obj, save_persistent_id)
576 reduce = getattr(obj, “reduce_ex”, None)
577 if reduce is not None:
–> 578 rv = reduce(self.proto)
579 else:
580 reduce = getattr(obj, “reduce”, None)
TypeError: cannot pickle ‘weakref’ object
用的sklearn 版本高于0.23
直接import joblib
想问新版本有没有办法解决?