前提・実現したいこと
下にあるパーセプトロンのプログラムを実行したいです。
発生している問題・エラーメッセージ
ファイル実行時に以下のエラーが出ます。
Traceback (most recent call last): File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module> from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed with error code 3221225501 while importing _pywrap_tensorflow_internal During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\__init__.py", line 3, in <module> from tensorflow.keras.layers.experimental.preprocessing import RandomRotation File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module> from tensorflow.python.tools import module_util as _module_util File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\__init__.py", line 39, in <module> from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module> from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed with error code 3221225501 while importing _pywrap_tensorflow_internal Failed to load the native TensorFlow runtime. See https://www.tensorflow.org/install/errors for some common reasons and solutions. Include the entire stack trace above this error message when asking for help. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "e:/○○/○○/AI/AI.py", line 1, in <module> from keras.models import Sequential File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\__init__.py", line 5, in <module> raise ImportError( ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via `pip install tensorflow`
該当のソースコード
Python
1from keras.models import Sequential 2from keras.layers import Activation, Dense 3 4 5model = Sequential() 6model.add(Dense(3, input_dim=2)) 7model.add(Activation('sigmoid')) 8model.add(Dense(1)) 9model.add(Activation('sigmoid')) 10model.summary()
試したこと
いくつかエラーについて調べて以下のことをしましたが、それぞれについて自分にはよく分からず、やっていることが正しいかどうかは分かりません。
・tensorflow、tensorboard、kerasのアップデートをしましたが改善されませんでした。
・Keras-2.3.1にダウングレードして実行したところ、
Using TensorFlow backend. Traceback (most recent call last): File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module> from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed with error code 3221225501 while importing _pywrap_tensorflow_internal During handling of the above exception, another exception occurred: Traceback (most recent call last): File "e:/○○/○○/AI/AI.py", line 1, in <module> from keras.models import Sequential File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\__init__.py", line 3, in <module> from . import utils File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\utils\__init__.py", line 6, in <module> from . import conv_utils File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module> from .. import backend as K File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\backend\__init__.py", line 1, in <module> from .load_backend import epsilon File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\backend\load_backend.py", line 90, in <module> from .tensorflow_backend import * File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module> import tensorflow as tf File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module> from tensorflow.python.tools import module_util as _module_util File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\__init__.py", line 39, in <module> from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module> from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed with error code 3221225501 while importing _pywrap_tensorflow_internal Failed to load the native TensorFlow runtime. See https://www.tensorflow.org/install/errors for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.
というように変化しました。
・tensorflow-1.5.0へのダウングレードを試みたところ、
ERROR: Could not find a version that satisfies the requirement TensorFlow==1.5.0 ERROR: No matching distribution found for TensorFlow==1.5.0
というエラーが出ました。
補足情報(FW/ツールのバージョンなど)
OS・・・Windows7 Home Premium
テキストエディタ・・・Visual Studio Code
言語・・・Python3.8.6(64-bit)
pip listの結果
Package Version ---------------------- --------- absl-py 0.11.0 astunparse 1.6.3 cachetools 4.2.0 certifi 2020.12.5 chardet 4.0.0 cycler 0.10.0 flatbuffers 1.12 gast 0.3.3 google-auth 1.24.0 google-auth-oauthlib 0.4.2 google-pasta 0.2.0 grpcio 1.32.0 h5py 2.10.0 idna 2.10 Keras 2.4.3 Keras-Applications 1.0.8 Keras-Preprocessing 1.1.2 kiwisolver 1.3.1 Markdown 3.3.3 matplotlib 3.3.3 numpy 1.19.5 oauthlib 3.1.0 opt-einsum 3.3.0 pandas 1.2.0 Pillow 8.1.0 pip 20.3.3 protobuf 3.14.0 pyasn1 0.4.8 pyasn1-modules 0.2.8 pyparsing 2.4.7 python-dateutil 2.8.1 pytz 2020.5 PyYAML 5.3.1 requests 2.25.1 requests-oauthlib 1.3.0 rsa 4.7 scipy 1.6.0 setuptools 49.2.1 six 1.15.0 tensorboard 2.4.0 tensorboard-plugin-wit 1.7.0 tensorflow 2.4.0 tensorflow-estimator 2.4.0 termcolor 1.1.0 typing-extensions 3.7.4.3 urllib3 1.26.2 Werkzeug 1.0.1 wheel 0.36.2 wrapt 1.12.1
###追加で試したこと
・以下のコード(HelloQ様が回答して下さったもの)
Python
1from tensorflow.keras.models import Sequential 2from tensorflow.keras.layers import Activation, Dense 3 4 5model = Sequential() 6model.add(Dense(3, input_dim=2)) 7model.add(Activation('sigmoid')) 8model.add(Dense(1)) 9model.add(Activation('sigmoid')) 10model.summary()
を実行したところ、kerasに関するエラーは改善しましたが、
Traceback (most recent call last): File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module> from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed with error code 3221225501 while importing _pywrap_tensorflow_internal During handling of the above exception, another exception occurred: Traceback (most recent call last): File "e:/○○/○○/AI/AI.py", line 1, in <module> from tensorflow.keras.models import Sequential File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module> from tensorflow.python.tools import module_util as _module_util File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\__init__.py", line 39, in <module> from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "C:\Users\○○\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module> from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed with error code 3221225501 while importing _pywrap_tensorflow_internal Failed to load the native TensorFlow runtime. See https://www.tensorflow.org/install/errors for some common reasons and solutions. Include the entire stack trace above this error message when asking for help.
という似たような別のエラーが出ました。(エラーコードは同じ。)
回答3件
あなたの回答
tips
プレビュー