最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

關(guān)于win10在tensorflow的安裝及在pycharm中運(yùn)行步驟詳解

 更新時間:2020年03月16日 14:50:50   作者:星空比上  
這篇文章主要介紹了關(guān)于win10在tensorflow的安裝及在pycharm中運(yùn)行的步驟詳解,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

本文介紹在win10中安裝tensorflow的步驟:

1、安裝anaconda3

2、新建conda環(huán)境變量,可建多個環(huán)境在內(nèi)部安裝多個tensorflow版本,1.x和2.x版本功能差別太大,代碼也很大區(qū)別

3、環(huán)境中安裝python和fensorflow

4、用tensorflow運(yùn)行一段測試程序

安裝anaconda下載地址(清華鏡像):

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/選擇最新版本

在這里插入圖片描述

開始安裝anaconda

在這里插入圖片描述在這里插入圖片描述在這里插入圖片描述

選擇安裝位置

在這里插入圖片描述

勾選后,點擊 install

在這里插入圖片描述

等待一段時間

在這里插入圖片描述

安裝完成,直接退出

在這里插入圖片描述 在這里插入圖片描述 在這里插入圖片描述

安裝好anaconda以后,打開cmd輸入conda --version” ----->得到conda 4.7.12,安裝成功

在這里插入圖片描述

anaconda3就安裝好了

開始安裝tensorflow

國外原地址下載太慢,這里設(shè)置國內(nèi)鏡像源,否則特別慢。。。。:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/    

conda config --set show_channel_urls yes

在這里插入圖片描述 查看Python版本

我們先安裝tensorflow2.0版本創(chuàng)建新的環(huán)境tensorflow2,輸入: conda create -n tensorflow2 python=3.7

在這里插入圖片描述

輸入 y

開始自動下載文件(可以看到下載的Python版本為3.7.6版本,文件目錄在E:\anaconda3\envs中,后面配置時會用到),

在這里插入圖片描述

激活剛才創(chuàng)建的環(huán)境,輸入 : activate tensorflow2

在這里插入圖片描述

然后就開始安裝TensorFlow,輸入: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==2.0.0-beta1

在這里插入圖片描述

接下來自動安裝好了,出現(xiàn)下面提示就安裝好了,哈哈!

在這里插入圖片描述

python的版本不一樣,運(yùn)行環(huán)境也不一樣,如果還要安裝1.x版本,(這里安裝tensorflow1.9.0版本),再次進(jìn)入cmd中

創(chuàng)建新的1.x版本環(huán)境

輸入 :conda create -n tensorflow1 python=3.6 激活新環(huán)境

輸入 : activate tensorflow1 安裝TensorFlow

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

在這里插入圖片描述

安裝過程中,如需pip9.0.1升級pip20:

輸入 python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple

運(yùn)行tensorflow

既然fensorflow安裝好了,我現(xiàn)在用pycharm打開運(yùn)行一段代碼,首先配置pycharm

在這里插入圖片描述

打開設(shè)置–項目–項目編輯器–點擊Add

在這里插入圖片描述

按下面步驟,設(shè)置環(huán)境就ok了

(https://img-

我們設(shè)置一個新環(huán)境,將環(huán)境再改為剛安裝好的tensorflow1.9.0的版本,測試運(yùn)行一個小程序。

# -*- coding: utf-8 -*-
"""
Created on Mon Nov 19 19:33:03 2018
@author: KUMA
"""
import numpy as np
import tensorflow as tf
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
class LinearSep:
 def __init__(self):
 self.n_train = 10
 self.n_test = 50
 self.x_train, self.y_train, self.x_test, self.y_test = self._gene_data()
 def _gene_data(self):
 x = np.random.uniform(-1, 1, [self.n_train, 2])
 y = (x[:, 1] > x[:, 0]).astype(np.int32)
 x += np.random.randn(self.n_train, 2) * 0.05
 x_test = np.random.uniform(-1, 1, [self.n_test, 2])
 y_test = (x_test[:, 1] > x_test[:, 0]).astype(np.int32)
 return x, y, x_test, y_test
# 隨機(jī)生成數(shù)據(jù)
dataset = LinearSep()
X_train, Y_train = dataset.x_train, dataset.y_train
print(Y_train)
Y_train = np.eye(2)[Y_train]
X_test, Y_test = dataset.x_test, dataset.y_test
Y_test = np.eye(2)[Y_test]
x = tf.placeholder(tf.float32, [None, 2], name='input')
y = tf.placeholder(tf.float32, [None, 2], name='output')
w1 = tf.get_variable(name='w_fc1', shape=[2, 20], dtype=tf.float32)
b1 = tf.get_variable(name='b_fc1', shape=[20], dtype=tf.float32)
out = tf.matmul(x, w1) + b1
out = tf.nn.relu(out)
w2 = tf.get_variable(name='w_fc2', shape=[20, 2], dtype=tf.float32)
b2 = tf.get_variable(name='b_fc2', shape=[2], dtype=tf.float32)
out = tf.matmul(out, w2) + b2
out = tf.nn.softmax(out)
# cross entropy 損失函數(shù)
loss = -tf.reduce_mean(tf.reduce_sum(y * tf.log(out + 1e-8), axis=1), axis=0)
# 準(zhǔn)確率
correct_pred = tf.equal(tf.argmax(y, axis=1), tf.argmax(out, axis=1))
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))
# 定義優(yōu)化器
train_op = tf.train.AdamOptimizer(1e-3).minimize(loss) # 1e-3 是學(xué)習(xí)律
# 初始化網(wǎng)絡(luò)
# BATCH_SIZE = 128
EPOCH = 7000 # 優(yōu)化次數(shù)
sess = tf.Session()
sess.run(tf.global_variables_initializer())
for ep in range(EPOCH):
 sess.run(train_op, feed_dict={x: X_train, y: Y_train})
 loss_train, acc_train = sess.run([loss, accuracy], feed_dict={x: X_train, y: Y_train})
 acc_test, pre_test = sess.run([accuracy, correct_pred], feed_dict={x: X_test, y: Y_test})
 if ep % 1000 == 0:
 print(ep, loss_train, acc_train, acc_test)
 print(Y_test.shape)
test_pre = sess.run(out, feed_dict={x: X_test, y: Y_test})
print(len(test_pre))
mask = np.argmax(test_pre, axis=1)
print(mask)
mask_0 = np.where(mask == 0)
mask_1 = np.where(mask == 1)
X_0 = X_train[mask_0]
X_1 = X_train[mask_1]
print(X_0)

結(jié)果如下:

`[1 0 1 0 1 1 1 0 1 1] T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

0 0.81077516 0.1 0.34 (50, 2) 1000 0.013808459 1.0 0.82 (50, 2) 2000 0.0025899492 1.0 0.82 (50, 2) 3000 0.00088921207 1.0 0.82 (50, 2) 4000 0.00038405406 1.0 0.82 (50, 2) 5000 0.0001859894 1.0 0.82 (50, 2) 6000 8.420033e-05 1.0 0.82 (50, 2) 50 [0 1 1 1 0 0 1 1 1 1 1 1 0 1 0 0 1 1 0 1 1 0 0 0 1 1 1 0 1 1 1 1 1 1 1 1 0 0 1 1 0 1 0 0 1 1 0 1 1 1]`

其中出現(xiàn) Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 這個沒問題,可以忽略,能正常運(yùn)行出結(jié)果。

總結(jié)

到此這篇關(guān)于關(guān)于win10在tensorflow的安裝及在pycharm中運(yùn)行步驟詳解的文章就介紹到這了,更多相關(guān)tensorflow安裝pycharm運(yùn)行內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

瓮安县| 钟山县| 舟山市| 肇庆市| 合肥市| 西平县| 新蔡县| 百色市| 湖州市| 文化| 翁源县| 勃利县| 榆社县| 仪陇县| 西华县| 哈密市| 长葛市| 苏尼特左旗| 上杭县| 二手房| 平邑县| 永康市| 江油市| 若羌县| 拉萨市| 巴塘县| 临西县| 仙居县| 丹寨县| 鄯善县| 塘沽区| 海宁市| 鹤峰县| 中阳县| 阿鲁科尔沁旗| 伊通| 鞍山市| 阿拉善左旗| 上饶市| 乐平市| 施秉县|