• 安装Keras,tensorflow,并将虚拟环境添加到jupyter notebook


    写在面前:

    最近需要用LSTM,今天开始搭环境,遇到了很多问题,其中主要是两个问题,不太懂装环境的朋友可以注意一下:

    1、tensorflow和keras以及numpy等等版本的兼容问题。一般的keras安装教程tensorflow和keras版本都是兼容的,但是自己还得去装numpy,一不小心版本就不兼容了,所以我的每一步安装都规定了版本,防止不兼容问题;

    2、因为用不惯pycharm,所以keras安装好了我想用jupyter打开,结果遇到了各种问题。例如无法识别jupyter notebook这个命令等等。所以我索性改变思路,先把虚拟环境加入到jupyter中,然后再在虚拟环境里面装包。

    以下是我安装的全过程,都是用的清华园镜像,网速好两三分钟就能全部装好!

    ——————————————————————————————————————————

    第一步:创建虚拟环境(tf3是我的虚拟环境的名称,你可以自己取)

    conda create -n tf3 python=3.6.5   
    

    第二步:安装 ipykernel

    pip install ipykernel -i https://pypi.tuna.tsinghua.edu.cn/simple/

    第三步:把新建的虚拟环境(tf3)加入到jupter notebook里面

    python -m ipykernel install --name tf3

    截至这里,虚拟环境就加入到jupter notebook里面了,接下来往虚拟环境装tensorflow和keras

    第一步:首先要进入到新建的虚拟环境

    conda activate tf3

     第二步:安装tensorflow

    pip install tensorflow==2.3.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/

    第三步:安装keras

    pip install keras==2.4.3 -i https://pypi.tuna.tsinghua.edu.cn/simple/

    第四步:安装numpy

    pip install numpy==1.19.5 -i https://pypi.tuna.tsinghua.edu.cn/simple/

    第五步:安装pandas

    pip install pandas==1.1.4 -i https://pypi.tuna.tsinghua.edu.cn/simple/

    第六步:安装scikit-learn 

    pip install scikit-learn==0.24.1 -i https://pypi.tuna.tsinghua.edu.cn/simple/

    第七步:安装scipy

    pip install scipy==1.5.4 -i https://pypi.tuna.tsinghua.edu.cn/simple/

    第八步:安装matplotlib

    pip install matplotlib==3.3.3 -i https://pypi.tuna.tsinghua.edu.cn/simple/

    最后在jupyter notebook里面引入相关库,没报错就说明ok了

    1. from keras.models import Sequential
    2. from keras.layers import Dense
    3. from keras.layers import LSTM
    4. from keras.layers import Dropout

  • 相关阅读:
    LeetCode75——Day31
    【AI数学】交叉熵损失函数CrossEntropy
    银行业务队列简单模拟(队列应用)
    YOLOv5的Tricks | 【Trick14】YOLOv5的val.py脚本的解析
    k8s安装3节点集群Fate v1.8.0
    C语言中文网 - Shell脚本 - 6
    掌握高等数学、线性代数、概率论所需数学知识及标题建议
    Learn Prompt-Prompt 高级技巧:AutoGPT
    对 scroll 的认知和探索
    【excel】列转行
  • 原文地址:https://blog.csdn.net/qq_42183184/article/details/125622442