中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

建站公司maxsem競(jìng)價(jià)托管多少錢

建站公司max,sem競(jìng)價(jià)托管多少錢,網(wǎng)站建設(shè)定義是什么意思,做 愛 網(wǎng)站小視頻下載在 TensorFlow 2.0 及之后的版本中,默認(rèn)采用 Eager Execution 的方式,不再使用 1.0 版本的 Session 創(chuàng)建會(huì)話。Eager Execution 使用更自然地方式組織代碼,無需構(gòu)建計(jì)算圖,可以立即進(jìn)行數(shù)學(xué)計(jì)算,簡(jiǎn)化了代碼調(diào)試的過程?!?article class="baidu_pl">

在 TensorFlow 2.0 及之后的版本中,默認(rèn)采用?Eager Execution 的方式,不再使用 1.0 版本的 Session 創(chuàng)建會(huì)話。Eager Execution 使用更自然地方式組織代碼,無需構(gòu)建計(jì)算圖,可以立即進(jìn)行數(shù)學(xué)計(jì)算,簡(jiǎn)化了代碼調(diào)試的過程。本文主要介紹 TensorFlow 的基本用法,通過構(gòu)建一個(gè)簡(jiǎn)單損失函數(shù),介紹 TensorFlow 優(yōu)化損失函數(shù)的過程。

目錄

1 tf.Tensor

2 tf.Variable

3 tf.GradientTape


TensorFlow 是一個(gè)用于機(jī)器學(xué)習(xí)的端到端平臺(tái)。它支持以下內(nèi)容:

  • 基于多維數(shù)組的數(shù)值計(jì)算(類似于 NumPy)
  • GPU 和分布式處理
  • 自動(dòng)微分
  • 模型構(gòu)建、訓(xùn)練和導(dǎo)出

1 tf.Tensor


????????TensorFlow 用 tf.Tensor 對(duì)象處理多維數(shù)組(或張量),以下是一個(gè) 2 維張量例子:

import tensorflow as tf
x = tf.constant([[1., 2., 3.],[4., 5., 6.]])
print(x)

tf.Tensor(
[[1. 2. 3.]
?[4. 5. 6.]], shape=(2, 3), dtype=float32)

tf.Tensor 對(duì)象最重要的屬性是 shape 與 dtype:

  • Tensor.shape? 返回張量每個(gè)維度的大小
  • Tensor.dtype? ?返回張量中元素的數(shù)據(jù)類型

print(x.shape)

(2, 3)

print(x.dtype)

<dtype: 'float32'>

????????TensorFlow 實(shí)現(xiàn)了張量的標(biāo)準(zhǔn)數(shù)學(xué)運(yùn)算,同時(shí)也包括為機(jī)器學(xué)習(xí)定制的運(yùn)算。以下是一些示例:

x + x
5 * x
tf.transpose(x)
tf.nn.softmax(x, axis=-1)
tf.reduce_sum(x)

2 tf.Variable

????????在 TensorFlow 中,模型的權(quán)重用 tf.Variable 對(duì)象存儲(chǔ),稱為變量。

import tensorflow as tfx = tf.Variable([0., 0., 0.])
x.assign([1, 2, 3])

<tf.Variable 'UnreadVariable' shape=(3,) dtype=float32,?
numpy=array([1., 2., 3.], dtype=float32)>

????????tf.Variable 對(duì)象的數(shù)值可以改變,在 TensorFlow 2.0 中,不再使用 Session 啟動(dòng)計(jì)算,變量可以直接算出結(jié)果。

x.assign_add([1, 1, 1,])

<tf.Variable 'UnreadVariable' shape=(3,) dtype=float32,?
numpy=array([2., 3., 4.], dtype=float32)>

x.assign_sub([1, 1, 1])

<tf.Variable 'UnreadVariable' shape=(3,) dtype=float32,?
numpy=array([1., 2., 3.], dtype=float32)>

3 tf.GradientTape

????????梯度下降法與相關(guān)算法是現(xiàn)在機(jī)器學(xué)習(xí)的基礎(chǔ)。TensorFLow 實(shí)現(xiàn)了自動(dòng)微分來計(jì)算梯度,通常用于計(jì)算機(jī)器學(xué)習(xí)模型的損失函數(shù)的梯度。

? ? ? ? TensorFlow 2.0 提供了 tf.GradientTape 對(duì)象,可以理解為“梯度流”,顧名思義,tf.GradientTape 是用來計(jì)算梯度用的。

????????以下是一個(gè)簡(jiǎn)單的示例:

import tensorflow as tfdef f(x):return x**2 + 2*x - 5x = tf.Variable(1.0)with tf.GradientTape() as tape:y = f(x)
g_x = tape.gradient(y, x) # 計(jì)算 y 在 x = 1.0 處的梯度
print(g_x)

4.0

最后,構(gòu)建一個(gè)簡(jiǎn)單損失函數(shù),并使用 TensorFlow 計(jì)算最小值。

import tensorflow as tfdef loss(x):return x**2 - 10*x + 25x = tf.Variable(1.0) # 隨機(jī)初始值losses = [] # 記錄損失函數(shù)值
for i in range(100):with tf.GradientTape() as tape:one_loss = loss(x)lossed.append(one_loss)grad = tape.gradient(one_loss, x)x.assign_sub(0.1 * grad) # 執(zhí)行一次梯度下降法print("The mininum of loss function is: ")
tf.print(x)

The mininum of loss function is:?

4.99999905

# 可視化優(yōu)化過程
import matplotlib
from matplotlib import pyplot as pltmatplotlib.rcParams['figure.figsize'] = [8, 5]plt.figure()
plt.plot(losses)
plt.title('Loss vs training iterations')
plt.xlabel('iterations')
plt.ylabel('loss')

http://www.risenshineclean.com/news/53675.html

相關(guān)文章:

  • 網(wǎng)站開發(fā)人月薪網(wǎng)絡(luò)營銷方法有哪幾種
  • 做現(xiàn)貨IC電子網(wǎng)站的惠州seo計(jì)費(fèi)管理
  • 做網(wǎng)站有地域限制嗎專業(yè)seo站長工具
  • 二級(jí)域名子域名大全領(lǐng)碩網(wǎng)站seo優(yōu)化
  • 淘寶網(wǎng)作圖做網(wǎng)站網(wǎng)站托管代運(yùn)營
  • wordpress買域名百度搜索排名優(yōu)化哪家好
  • 如何注銷網(wǎng)站備案號(hào)數(shù)據(jù)分析培訓(xùn)班
  • 網(wǎng)站的運(yùn)營管理方案長沙seo結(jié)算
  • seo如何根據(jù)網(wǎng)站數(shù)據(jù)做報(bào)表怎么找專業(yè)的營銷團(tuán)隊(duì)
  • 如何做轉(zhuǎn)運(yùn)網(wǎng)站引流推廣犯法嗎
  • wordpress添加版權(quán)信息如何進(jìn)行網(wǎng)站性能優(yōu)化
  • 怎么做直播網(wǎng)站超管做網(wǎng)絡(luò)推廣的團(tuán)隊(duì)
  • 有道網(wǎng)站提交入口網(wǎng)站推廣論壇
  • 釣魚網(wǎng)站到底怎么做株洲網(wǎng)站設(shè)計(jì)外包首選
  • 網(wǎng)站建設(shè)與域名建設(shè)國際時(shí)事新聞最新消息
  • 建網(wǎng)站為什么每年都要續(xù)費(fèi)鄭州seo博客
  • java 網(wǎng)站制作汽車營銷策劃方案ppt
  • 上海營銷型網(wǎng)站設(shè)計(jì)蚌埠seo外包
  • 上海找做網(wǎng)站公司哪家好google google
  • 重慶網(wǎng)站聯(lián)盟鄭州競(jìng)價(jià)代運(yùn)營公司
  • 國外最大的設(shè)計(jì)網(wǎng)站有哪些方面seo外鏈網(wǎng)
  • 《商務(wù)網(wǎng)站開發(fā)》 實(shí)訓(xùn)報(bào)告書網(wǎng)絡(luò)營銷的主要傳播渠道是
  • 珠海做網(wǎng)站方案熱搜榜上2023年熱門話題
  • 深圳寶安網(wǎng)站建設(shè)廣告公司推廣軟文
  • 專業(yè)網(wǎng)站定制設(shè)計(jì)公司網(wǎng)絡(luò)營銷過程步驟
  • 淘客怎么建網(wǎng)站做推廣seo程序
  • 無錫網(wǎng)站建設(shè)技術(shù)搜索引擎營銷分類
  • 成都個(gè)人學(xué)做網(wǎng)站如何推廣小程序平臺(tái)
  • 海淀做網(wǎng)站好的公司google免費(fèi)入口
  • 自己如何做團(tuán)購網(wǎng)站信息流廣告素材網(wǎng)站