TensorFlow is an end-to-end open source platform for machine learning TensorFlow 是一个端到端的开源机器学习平台,性能好,但代码风格稍微底层 为了让开发者更方便的使用TensorFlow,写了一套更加简单易用的API,然后命名为keras Keras 是一个用 Python 编写的高级神经网络 API,它以TensorFlow或CNTK等其他框架为后端。
推荐使用ubantu,新建一个用户,进行下面的安装, 没有conda就是先安装conda,安装到新建的tf1下面 [/home/tf1/anaconda3] >>> PREFIX=/home/tf1/anaconda3 以后这个环境就是tf1的学习环境 之所以这做,是为了将tf1环境与现有的python环境彻底分隔开,如果你是高级玩家,放一块没问题,遇到问题解决就可以了 通过Keras调用tensorflow,有GPU环境就安装GPU版本的tensorflow,keras本身无CPU,GPU之分 示例一 --------------------------------------------------- 先查看有哪些环境 conda env list conda create --name py36 python=3.6 conda activate py36 conda deactivate pip install numpy==1.18.1 pip install matplotlib==3.3.4 pip install pandas==1.1.5 pip install scikit-learn==0.24.2 conda install tensorflow=1.15.0 pip install Keras==2.0.0 windows环境补充安装 pip install win_unicode_console 设置自定义python模块路径 python -c "print('\n'.join(__import__('sys').path))" --------------------------------------------------- import tensorflow as tf print(tf.test.is_gpu_available()) conda uninstall tensorflow=1.15.0 conda uninstall tensorflow-gpu=1.15.0 pip uninstall tensorflow-gpu=1.15.0 ------------------------------------------------ >>> import keras Using TensorFlow backend. 警告处理,Passing (type, 1) or '1type' as a synonym of type is deprecate 修改dtype.py对应行的代码,把np.dtype([("quint8", np.uint8, 1)])修改为np.dtype([("quint8", np.uint8, (1,))])
tensorflow2 windows安装
3.11不行的,3.10可以(2024-06-12) -U 表示更新安装 conda create -n py310 python=3.10 conda activate py310 conda install mingw libpython conda install theano pip install -U numpy==1.22.4 pip install -U pandas==2.1.0 pip install -U protobuf==3.9.2 pip install -U tensorflow-io-gcs-filesystem==0.23.1 pip install -U libclang==13.0.0 pip install -U tensorflow==2.10.0 pip install -U keras==2.10.0 pip install -U matplotlib==3.8.4 conda deactivate
(py310) PS C:\Users\83933> pip list Package Version --------------------------------- -------------- absl-py 2.1.0 aiohttp 3.9.5 aiosignal 1.2.0 anyio 4.4.0 argon2-cffi 23.1.0 argon2-cffi-bindings 21.2.0 arrow 1.3.0 asttokens 2.4.1 astunparse 1.6.3 async-lru 2.0.4 async-timeout 4.0.3 attrs 23.1.0 Babel 2.15.0 beautifulsoup4 4.12.3 bleach 6.1.0 blinker 1.6.2 Brotli 1.0.9 cachetools 5.3.3 certifi 2024.6.2 cffi 1.16.0 charset-normalizer 2.0.4 click 8.1.7 colorama 0.4.6 comm 0.2.2 contourpy 1.2.1 cryptography 41.0.3 cycler 0.12.1 debugpy 1.8.1 decorator 5.1.1 defusedxml 0.7.1 exceptiongroup 1.2.1 executing 2.0.1 fastjsonschema 2.19.1 flatbuffers 2.0 fonttools 4.53.0 fqdn 1.5.1 frozenlist 1.4.0 gast 0.4.0 google-auth 2.29.0 google-auth-oauthlib 0.4.4 google-pasta 0.2.0 grpcio 1.42.0 h11 0.14.0 h5py 3.11.0 httpcore 1.0.5 httpx 0.27.0 idna 3.7 ipykernel 6.29.4 ipython 8.25.0 isoduration 20.11.0 jedi 0.19.1 Jinja2 3.1.4 json5 0.9.25 jsonpointer 3.0.0 jsonschema 4.22.0 jsonschema-specifications 2023.12.1 jupyter_client 8.6.2 jupyter_contrib_core 0.4.2 jupyter_core 5.7.2 jupyter-events 0.10.0 jupyter-lsp 2.2.5 jupyter_nbextensions_configurator 0.6.4 jupyter_server 2.14.1 jupyter_server_terminals 0.5.3 jupyterlab 4.2.2 jupyterlab_pygments 0.3.0 jupyterlab_server 2.27.2 keras 2.10.0 Keras-Preprocessing 1.1.2 kiwisolver 1.4.5 libclang 13.0.0 Mako 1.2.3 Markdown 3.4.1 MarkupSafe 2.1.3 matplotlib 3.8.4 matplotlib-inline 0.1.7 mistune 3.0.2 mkl-fft 1.3.1 mkl-random 1.2.2 mkl-service 2.4.0 multidict 6.0.4 nbclient 0.10.0 nbconvert 7.16.4 nbformat 5.10.4 nest-asyncio 1.6.0 notebook 7.2.1 notebook_shim 0.2.4 numpy 1.22.4 oauthlib 3.2.2 opt-einsum 3.3.0 overrides 7.7.0 packaging 23.2 pandas 2.1.0 pandocfilters 1.5.1 parso 0.8.4 pillow 10.3.0 pip 24.0 platformdirs 4.2.2 prometheus_client 0.20.0 prompt_toolkit 3.0.47 protobuf 3.9.2 psutil 5.9.8 pure-eval 0.2.2 pyasn1 0.4.8 pyasn1-modules 0.2.8 pycparser 2.21 Pygments 2.18.0 pygpu 0.7.6 PyJWT 2.8.0 pyOpenSSL 23.2.0 pyparsing 3.1.2 PySocks 1.7.1 python-dateutil 2.9.0.post0 python-json-logger 2.0.7 pytz 2024.1 pywin32 306 pywinpty 2.0.13 PyYAML 6.0.1 pyzmq 26.0.3 referencing 0.35.1 requests 2.32.2 requests-oauthlib 1.3.0 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 rpds-py 0.18.1 rsa 4.7.2 scipy 1.7.3 Send2Trash 1.8.3 setuptools 69.5.1 six 1.16.0 sniffio 1.3.1 soupsieve 2.5 stack-data 0.6.3 tensorboard 2.10.0 tensorboard-data-server 0.6.1 tensorboard-plugin-wit 1.8.1 tensorflow 2.10.0 tensorflow-estimator 2.10.0 tensorflow-io-gcs-filesystem 0.23.1 termcolor 2.1.0 terminado 0.18.1 Theano 1.0.5 tinycss2 1.3.0 tomli 2.0.1 tornado 6.4.1 traitlets 5.14.3 types-python-dateutil 2.9.0.20240316 typing_extensions 4.11.0 tzdata 2024.1 uri-template 1.3.0 urllib3 2.2.1 wcwidth 0.2.13 webcolors 24.6.0 webencodings 0.5.1 websocket-client 1.8.0 Werkzeug 3.0.3 wheel 0.43.0 win-inet-pton 1.1.0 wrapt 1.14.1 yarl 1.9.3