我试图在下面导入此模块,但出现奇怪的错误:
import keras
from keras import backend as K
from keras.models import Sequential
from keras.layers import Activation
from keras.layers.core import Dense
from keras.optimizers import Adam
from keras.metrics import categorical_crossentropy
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py in <module>
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
~\Anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py in <module>
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
~\Anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py in
swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname,
description)
25 finally:
~\Anaconda3\lib\imp.py in load_module(name, file, filename, details)
241 else:
--> 242 return load_dynamic(name, filename, file)
243 elif type_ == PKG_DIRECTORY:
~\Anaconda3\lib\imp.py in load_dynamic(name, path, file)
341 name=name, loader=loader, origin=path)
--> 342 return _load(spec)
343
ImportError: DLL load failed with error code 3221225501
During handling of the above exception, another exception occurred:
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in showtraceback(self, exc_tuple,
filename, tb_offset, exception_only, running_compiled_code)
2039 # in the engines. This should return a list of strings.
-> 2040 stb = value._render_traceback_()
2041 except Exception:
AttributeError: 'ImportError' object has no attribute '_render_traceback_'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_code(self, code_obj, result, async_)
3341 if result is not None:
3342 result.error_in_exec = sys.exc_info()[1]
-> 3343 self.showtraceback(running_compiled_code=True)
3344 else:
3345 outflag = False
~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in showtraceback(self, exc_tuple,
filename, tb_offset, exception_only, running_compiled_code)
2041 except Exception:
2042 stb = self.InteractiveTB.structured_traceback(etype,
-> 2043 value, tb, tb_offset=tb_offset)
2044
2045 self._showtraceback(etype, value, stb)
~\Anaconda3\lib\site-packages\IPython\core\ultratb.py in structured_traceback(self, etype, value, tb,
tb_offset, number_of_lines_of_context)
1383 self.tb = tb
1384 return FormattedTB.structured_traceback(
-> 1385 self, etype, value, tb, tb_offset, number_of_lines_of_context)
1386
1387
~\Anaconda3\lib\site-packages\IPython\core\ultratb.py in structured_traceback(self, etype, value, tb,
tb_offset, number_of_lines_of_context)
1286 # Verbose modes need a full traceback
1287 return VerboseTB.structured_traceback(
-> 1288 self, etype, value, tb, tb_offset, number_of_lines_of_context
1289 )
1290 elif mode == 'Minimal':
~\Anaconda3\lib\site-packages\IPython\core\ultratb.py in structured_traceback(self, etype, evalue,
etb, tb_offset, number_of_lines_of_context)
1148 exception = self.get_parts_of_chained_exception(evalue)
1149 if exception:
-> 1150 formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__)
1151 etype, evalue, etb = exception
1152 else:
TypeError: can only concatenate str (not "list") to str
我以前也有类似的陌生人错误。当我在Jupyter Notebook上遇到这些错误时,我只需要重新启动内核即可。我相信这可能是存储变量的问题。我建议您重新启动执行此代码的平台。如果您对此有任何疑问,我会尽力为您提供帮助。