如何在python中使用Tensorflow后端解决错误

时间:2019-06-23 17:04:13

标签: python anaconda python-3.7

当Iam在Anaconda IDE中运行github项目时,Iam遇到这样的错误“您能解释如何解决此错误”

.my-class .fusion-layout-column .fusion-column-wrapper {
    min-height: 1px;
    height: 600px;
}

1 个答案:

答案 0 :(得分:1)

您可以查看我正在使用哪个tensorflow,numpy,pandas版本。它工作得很好。所有版本的tensorflow都不好,但这对我来说很好。

absl-py==0.7.1
alabaster==0.7.11
altgraph==0.16.1
anaconda-client==1.7.2
anaconda-navigator==1.9.7
anaconda-project==0.8.2
appdirs==1.4.3
apyori==1.1.1
asn1crypto==0.24.0
astor==0.7.1
astroid==2.0.4
astropy==3.0.4
atomicwrites==1.2.1
attrs==18.2.0
Automat==0.7.0
Babel==2.6.0
backcall==0.1.0
backports.shutil-get-terminal-size==1.0.0
beautifulsoup4==4.6.3
bitarray==0.8.3
bkcharts==0.2
blaze==0.11.3
bleach==2.1.4
bokeh==1.2.0
boto==2.49.0
Bottleneck==1.2.1
Cartopy==0.17.0
certifi==2019.3.9
cffi==1.12.3
chardet==3.0.4
click==6.7
cloudpickle==0.5.5
clyent==1.2.2
cmake==3.13.3
colorama==0.3.9
colour==0.1.5
comtypes==1.1.7
conda==4.6.14
conda-build==3.15.1
constantly==15.1.0
contextlib2==0.5.5
corner==2.0.1
cryptography==2.6.1
cssselect==1.0.3
cycler==0.10.0
Cython==0.28.5
cytoolz==0.9.0.1
dask==0.19.1
datashape==0.5.4
decorator==4.3.0
defusedxml==0.5.0
distributed==1.23.1
Django==2.1.7
docutils==0.14
emcee==2.2.1
entrypoints==0.2.3
et-xmlfile==1.0.1
fastcache==1.0.2
filelock==3.0.8
Flask==1.0.2
Flask-Cors==3.0.6
future==0.17.1
gast==0.2.2
geoviews==1.6.2
gevent==1.3.6
glm==0.3.6
glob2==0.6
gmplot==1.2.0
greenlet==0.4.15
grpcio==1.19.0
h5py==2.9.0
heapdict==1.0.0
holoviews==1.12.3
html5lib==1.0.1
hyperlink==18.0.0
idna==2.8
imageio==2.4.1
imagesize==1.1.0
incremental==17.5.0
ipykernel==5.1.0
ipython==6.5.0
ipython-genutils==0.2.0
ipywidgets==7.4.1
isort==4.3.4
itsdangerous==0.24
jdcal==1.4
jedi==0.12.1
Jinja2==2.10
jsonpickle==1.2
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.2.4
jupyter-console==5.2.0
jupyter-core==4.4.0
jupyterlab==0.34.9
jupyterlab-launcher==0.13.1
Keras==2.2.4
Keras-Applications==1.0.7
Keras-Preprocessing==1.0.9
keyring==13.2.1
kiwisolver==1.1.0
lazy-object-proxy==1.3.1
llvmlite==0.24.0
locket==0.2.0
lxml==4.2.5
macholib==1.11
Markdown==3.1
MarkupSafe==1.0
matplotlib==3.1.0
mccabe==0.6.1
menuinst==1.4.16
mistune==0.8.3
mkl-fft==1.0.12
mkl-random==1.0.2
mock==2.0.0
more-itertools==4.3.0
mpmath==1.0.0
msgpack==0.5.6
multipledispatch==0.6.0
mysql-connector==2.2.9
navigator-updater==0.2.1
nbconvert==5.5.0
nbformat==4.4.0
networkx==2.1
nltk==3.3
nose==1.3.7
notebook==5.6.0
numba==0.39.0
numexpr==2.6.8
numpy==1.16.4
numpydoc==0.8.0
odo==0.5.1
olefile==0.46
opencv-contrib-python==4.0.0.21
opencv-python==4.0.0.21
openpyxl==2.5.6
OWSLib==0.17.1
packaging==17.1
pafy==0.5.4
pandas==0.24.2
pandas-datareader==0.7.0
pandocfilters==1.4.2
panel==0.6.0
param==1.9.1
parsel==1.5.1
parso==0.3.1
partd==0.3.8
path.py==11.1.0
pathlib2==2.3.2
patsy==0.5.0
pbr==5.1.3
pefile==2019.4.18
pep8==1.7.1
pickleshare==0.7.4
Pillow==6.0.0
pkginfo==1.4.2
pluggy==0.7.1
ply==3.11
prometheus-client==0.3.1
prompt-toolkit==1.0.15
protobuf==3.7.1
psutil==5.6.2
py==1.6.0
py4j==0.10.7
pyasn1==0.4.4
pyasn1-modules==0.2.2
pycodestyle==2.4.0
pycosat==0.6.3
pycparser==2.19
pycrypto==2.6.1
pyct==0.4.6
pycurl==7.43.0.2
PyDispatcher==2.0.5
pyepsg==0.4.0
pyflakes==2.0.0
Pygments==2.2.0
PyHamcrest==1.9.0
PyInstaller==3.4
pykdtree==1.3.1
pylint==2.1.1
pylyrics3==1.0.6
pyodbc==4.0.24
PyOpenGL==3.1.0
pyOpenSSL==19.0.0
pyparsing==2.4.0
pyproj==1.9.6
pyreadline==2.1
pyshp==2.1.0
PySocks==1.7.0
pyspark==2.4.3
pytest==3.8.0
pytest-arraydiff==0.2
pytest-astropy==0.4.0
pytest-doctestplus==0.1.3
pytest-openfiles==0.3.0
pytest-remotedata==0.3.0
python-dateutil==2.8.0
pytz==2018.5
pyviz-comms==0.7.2
PyWavelets==1.0.0
pywin32==223
pywin32-ctypes==0.2.0
pywinpty==0.5.4
PyYAML==5.1
pyzmq==18.0.0
QtAwesome==0.5.7
qtconsole==4.4.4
QtPy==1.5.0
queuelib==1.5.0
rainflow==2.1.2
randomcolor==0.4.4.5
requests==2.22.0
resource-allocator==0.1.0
rope==0.11.0
ruamel-yaml==0.15.46
scikit-image==0.14.0
scikit-learn==0.19.2
scipy==1.2.1
Scrapy==1.6.0
seaborn==0.9.0
selenium==3.141.0
Send2Trash==1.5.0
service-identity==17.0.0
Shapely==1.6.4.post1
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.12.0
sklearn==0.0
snowballstemmer==1.2.1
sortedcollections==1.0.1
sortedcontainers==2.0.5
Sphinx==1.7.9
sphinxcontrib-websupport==1.1.0
spotipy==2.4.4
spyder==3.3.4
spyder-kernels==0.4.4
SQLAlchemy==1.2.11
statsmodels==0.9.0
sympy==1.1.1
tables==3.4.4
tblib==1.3.2
tensorboard==1.13.1
tensorflow==1.13.1
tensorflow-estimator==1.13.0
tensorflow-gpu==1.13.1
termcolor==1.1.0
terminado==0.8.1
testpath==0.3.1
Theano==1.0.4+11.gbb2daf975
toolz==0.9.0
torch==1.1.0
torchvision==0.3.0
tornado==5.1
tqdm==4.32.1
traitlets==4.3.2
Twisted==18.7.0
unicodecsv==0.14.1
urllib3==1.24.2
urwid==2.0.1
vaderSentiment==3.2.1
vander==0.1
w3lib==1.20.0
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.15.2
widgetsnbextension==3.4.1
win-inet-pton==1.1.0
win-unicode-console==0.5
wincertstore==0.2
WMI==1.4.9
wrapt==1.10.11
xarray==0.12.1
xgboost==0.90
xlrd==1.1.0
XlsxWriter==1.1.0
xlwings==0.11.8
xlwt==1.3.0
youtube-dl==2019.6.8
zict==0.1.3
zope.interface==4.5.0

这是我的tensorflow环境列表,至少应通过在pycharm中创建requirements.txt并进行安装来进行安装。或通过pip install -r requirements.txt

absl-py==0.7.1
astor==0.7.1
backcall==0.1.0
certifi==2019.3.9
cloudpickle==1.0.0
colorama==0.4.1
cycler==0.10.0
decorator==4.4.0
gast==0.2.2
grpcio==1.16.1
h5py==2.9.0
ipykernel==5.1.0
ipython==7.5.0
ipython-genutils==0.2.0
jedi==0.13.3
joblib==0.13.2
jupyter-client==5.2.4
jupyter-core==4.4.0
Keras==2.2.4
Keras-Applications==1.0.7
Keras-Preprocessing==1.0.9
kiwisolver==1.1.0
Markdown==3.1
matplotlib==3.1.0
mkl-fft==1.0.12
mkl-random==1.0.2
mock==2.0.0
numpy==1.16.3
pandas==0.24.2
parso==0.4.0
pbr==5.1.3
pickleshare==0.7.5
prompt-toolkit==2.0.9
protobuf==3.7.1
Pygments==2.4.0
pyparsing==2.4.0
pyreadline==2.1
python-dateutil==2.8.0
pytz==2019.1
PyYAML==5.1
pyzmq==18.0.0
scikit-learn==0.21.2
scipy==1.2.1
six==1.12.0
sklearn==0.0
spyder-kernels==0.4.4
tensorboard==1.13.1
tensorflow==1.13.1
tensorflow-estimator==1.13.0
termcolor==1.1.0
tornado==6.0.2
traitlets==4.3.2
wcwidth==0.1.7
Werkzeug==0.15.2
wincertstore==0.2

安装所有软件包都需要花费一些时间和互联网,但要保持冷静。如果您安装了所有组件,那么您会没事的。

(opencv-env) C:\Users\jainil>pip install tensorflow==1.13.1
Collecting tensorflow==1.13.1
  Downloading https://files.pythonhosted.org/packages/bf/58/34bfa8fa17f86333361172b3b502e805195180f19a7496ad0f6149138d55/tensorflow-1.13.1-cp36-cp36m-win_amd64.whl (63.1MB)
    2% |█                               | 1.3MB 72kB/s eta 0:14:18

它在那里。看起来我尝试再次下载!它的屏幕截图。

enter image description here

C:\Users\jainil\Anaconda3\python.exe "C:\Program Files\JetBrains\PyCharm 2018.1.4\helpers\pydev\pydev_run_in_console.py" 57200 57201 C:/Users/jainil/Downloads/Compressed/Facial_emotion_recognition_using_Keras-master/realtime_facial_expression.py
Running C:/Users/jainil/Downloads/Compressed/Facial_emotion_recognition_using_Keras-master/realtime_facial_expression.py
import sys; print('Python %s on %s' % (sys.version, sys.platform))
sys.path.extend(['C:\\Users\\jainil\\PycharmProjects\\untitled', 'C:/Users/jainil/Downloads/Compressed/Facial_emotion_recognition_using_Keras-master'])
Using TensorFlow backend.
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.
2019-06-25 16:01:14.103440: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
WARNING:tensorflow:From C:\Users\jainil\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From C:\Users\jainil\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.
WARNING:tensorflow:From C:\Users\jainil\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
C:\Users\jainil\Anaconda3\lib\site-packages\keras\engine\saving.py:327: UserWarning: Error in loading the saved optimizer state. As a result, your model is starting with a freshly initialized optimizer.
  warnings.warn('Error in loading the saved optimizer '

最后在image_test.py中,您可以编写:

if __name__=='__main__':
    image_addres = './tes.jpg'
    test_image(image_addres)

因为您没有提供任何命令行参数。

enter image description here