zoukankan      html  css  js  c++  java
  • Tensorflow 安装和测试(Anaconda4.7.10+windows10)

    一. 软件下载

    二. 配置相关

    1. 修改 Jupyter notebook 默认工作路径

      (1)打开 Anaconda Prompt ,输入 jupyter notebook --generate-config,打开文件 C:Usersxxx.jupyterjupyter_notebook_config.py ,修改 c.NotebookApp.notebook_dir = 'G:StudyFilesPythonProjects'

      (2)修改快捷方式的启动路径

    2. 配置conda镜像源(参考 https://blog.csdn.net/Sagepyt/article/details/100740862

    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --set show_channel_urls yes

    3. conda常用的命令

     1)conda list 查看安装了哪些包。
        2)conda env list 或 conda info -e 查看当前存在哪些虚拟环境
        3)conda update conda 检查更新当前conda

    4.创建python虚拟环境
    conda create -n your_env_name python=X.X

    5.删除虚拟环境
    conda remove -n your_env_name(虚拟环境名称) --all

    6.删除环境中的某个包
    conda remove --name your_env_name  package_name

    7.jupyter-notebook添加python虚拟环境
    conda install -n tensorflow ipykernel

    8.生成ipykernel的配置文件(–name之后跟的是在jupyter-notebook中对应虚拟环境的kernel名称)
    python -m ipykernel install --name tensorflow-notebook

    9.测试代码

    import tensorflow as tf
    tf.compat.v1.disable_eager_execution()   # The Session graph is empty.  Add operations to the graph before calling run().
    sess = tf.compat.v1.Session()
    matrix1 = tf.constant([[3., 3.]])
    matrix2 = tf.constant([[2.],[2.]])
    product = tf.matmul(matrix1, matrix2)
    result = sess.run(product)
    print(result)
    
  • 相关阅读:
    C#中 ()=>的含义
    大白话系列之C#委托与事件讲解(三)
    大白话系列之C#委托与事件讲解(二)
    C#委托
    php.ini
    mac 登陆phpmyadmin 提示 mysqli_real_connect(): (HY000/2002): No such file or directory
    mac 安装 mysql 5.7
    Mac下的PHP的配置与运行
    phpstorm 2019.1 mac
    激活 phpstorm2019.1 win10
  • 原文地址:https://www.cnblogs.com/runningRain/p/12626571.html
Copyright © 2011-2022 走看看