chinese直男口爆体育生外卖, 99久久er热在这里只有精品99, 又色又爽又黄18禁美女裸身无遮挡, gogogo高清免费观看日本电视,私密按摩师高清版在线,人妻视频毛茸茸,91论坛 兴趣闲谈,欧美 亚洲 精品 8区,国产精品久久久久精品免费

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線(xiàn)課程
  • 觀看技術(shù)視頻
  • 寫(xiě)文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

PyTorch教程-2.5. 自動(dòng)微分

jf_pJlTbmA9 ? 來(lái)源:PyTorch ? 作者:PyTorch ? 2023-06-05 15:38 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

回想一下2.4 節(jié),計(jì)算導(dǎo)數(shù)是我們將用于訓(xùn)練深度網(wǎng)絡(luò)的所有優(yōu)化算法中的關(guān)鍵步驟。雖然計(jì)算很簡(jiǎn)單,但手工計(jì)算可能很乏味且容易出錯(cuò),而且這個(gè)問(wèn)題只會(huì)隨著我們的模型變得更加復(fù)雜而增長(zhǎng)。

幸運(yùn)的是,所有現(xiàn)代深度學(xué)習(xí)框架都通過(guò)提供自動(dòng)微分(通常簡(jiǎn)稱(chēng)為 autograd )來(lái)解決我們的工作。當(dāng)我們通過(guò)每個(gè)連續(xù)的函數(shù)傳遞數(shù)據(jù)時(shí),該框架會(huì)構(gòu)建一個(gè)計(jì)算圖來(lái)跟蹤每個(gè)值如何依賴(lài)于其他值。為了計(jì)算導(dǎo)數(shù),自動(dòng)微分通過(guò)應(yīng)用鏈?zhǔn)椒▌t通過(guò)該圖向后工作。以這種方式應(yīng)用鏈?zhǔn)椒▌t的計(jì)算算法稱(chēng)為反向傳播。

雖然 autograd 庫(kù)在過(guò)去十年中成為熱門(mén)話(huà)題,但它們的歷史悠久。事實(shí)上,對(duì) autograd 的最早引用可以追溯到半個(gè)多世紀(jì)以前(Wengert,1964 年)。現(xiàn)代反向傳播背后的核心思想可以追溯到 1980 年的一篇博士論文 ( Speelpenning, 1980 ),并在 80 年代后期得到進(jìn)一步發(fā)展 ( Griewank, 1989 )。雖然反向傳播已成為計(jì)算梯度的默認(rèn)方法,但它并不是唯一的選擇。例如,Julia 編程語(yǔ)言采用前向傳播 (Revels等人,2016 年). 在探索方法之前,我們先來(lái)掌握autograd這個(gè)包。

import torch

from mxnet import autograd, np, npx

npx.set_np()

from jax import numpy as jnp

import tensorflow as tf

2.5.1. 一個(gè)簡(jiǎn)單的函數(shù)

假設(shè)我們有興趣區(qū)分函數(shù) y=2x?x關(guān)于列向量x. 首先,我們分配x一個(gè)初始值。

x = torch.arange(4.0)
x

tensor([0., 1., 2., 3.])

在我們計(jì)算梯度之前y關(guān)于 x,我們需要一個(gè)地方來(lái)存放它。通常,我們避免每次求導(dǎo)時(shí)都分配新內(nèi)存,因?yàn)樯疃葘W(xué)習(xí)需要針對(duì)相同參數(shù)連續(xù)計(jì)算導(dǎo)數(shù)數(shù)千或數(shù)百萬(wàn)次,并且我們可能會(huì)面臨內(nèi)存耗盡的風(fēng)險(xiǎn)。請(qǐng)注意,標(biāo)量值函數(shù)相對(duì)于向量的梯度x是向量值的并且具有相同的形狀x.

# Can also create x = torch.arange(4.0, requires_grad=True)
x.requires_grad_(True)
x.grad # The gradient is None by default

x = np.arange(4.0)
x

array([0., 1., 2., 3.])

Before we calculate the gradient of y with respect to x, we need a place to store it. In general, we avoid allocating new memory every time we take a derivative because deep learning requires successively computing derivatives with respect to the same parameters thousands or millions of times, and we might risk running out of memory. Note that the gradient of a scalar-valued function with respect to a vector x is vector-valued and has the same shape as x.

# We allocate memory for a tensor's gradient by invoking `attach_grad`
x.attach_grad()
# After we calculate a gradient taken with respect to `x`, we will be able to
# access it via the `grad` attribute, whose values are initialized with 0s
x.grad

array([0., 0., 0., 0.])

x = jnp.arange(4.0)
x

No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)

Array([0., 1., 2., 3.], dtype=float32)

x = tf.range(4, dtype=tf.float32)
x


Before we calculate the gradient of y with respect to x, we need a place to store it. In general, we avoid allocating new memory every time we take a derivative because deep learning requires successively computing derivatives with respect to the same parameters thousands or millions of times, and we might risk running out of memory. Note that the gradient of a scalar-valued function with respect to a vector x is vector-valued and has the same shape as x.

x = tf.Variable(x)

我們現(xiàn)在計(jì)算我們的函數(shù)x并將結(jié)果分配給y。

y = 2 * torch.dot(x, x)
y

tensor(28., grad_fn=)

我們現(xiàn)在可以通過(guò)調(diào)用它的方法來(lái)獲取y關(guān)于的梯度。接下來(lái),我們可以通過(guò)的 屬性訪問(wèn)漸變。xbackwardxgrad

y.backward()
x.grad

tensor([ 0., 4., 8., 12.])

# Our code is inside an `autograd.record` scope to build the computational
# graph
with autograd.record():
  y = 2 * np.dot(x, x)
y

array(28.)

We can now take the gradient of y with respect to x by calling its backward method. Next, we can access the gradient via x’s grad attribute.

y.backward()
x.grad

[09:38:36] src/base.cc:49: GPU context requested, but no GPUs found.

array([ 0., 4., 8., 12.])

y = lambda x: 2 * jnp.dot(x, x)
y(x)

Array(28., dtype=float32)

We can now take the gradient of y with respect to x by passing through the grad transform.

from jax import grad

# The `grad` transform returns a Python function that
# computes the gradient of the original function
x_grad = grad(y)(x)
x_grad

Array([ 0., 4., 8., 12.], dtype=float32)

# Record all computations onto a tape
with tf.GradientTape() as t:
  y = 2 * tf.tensordot(x, x, axes=1)
y


We can now calculate the gradient of y with respect to x by calling the gradient method.

x_grad = t.gradient(y, x)
x_grad


我們已經(jīng)知道函數(shù)的梯度 y=2x?x關(guān)于 x應(yīng)該4x. 我們現(xiàn)在可以驗(yàn)證自動(dòng)梯度計(jì)算和預(yù)期結(jié)果是否相同。

x.grad == 4 * x

tensor([True, True, True, True])

現(xiàn)在讓我們計(jì)算另一個(gè)函數(shù)x并獲取它的梯度。請(qǐng)注意,當(dāng)我們記錄新的梯度時(shí),PyTorch 不會(huì)自動(dòng)重置梯度緩沖區(qū)。相反,新的漸變被添加到已經(jīng)存儲(chǔ)的漸變中。當(dāng)我們想要優(yōu)化多個(gè)目標(biāo)函數(shù)的總和時(shí),這種行為會(huì)派上用場(chǎng)。要重置梯度緩沖區(qū),我們可以調(diào)用x.grad.zero()如下:

x.grad.zero_() # Reset the gradient
y = x.sum()
y.backward()
x.grad

tensor([1., 1., 1., 1.])

x.grad == 4 * x

array([ True, True, True, True])

Now let’s calculate another function of x and take its gradient. Note that MXNet resets the gradient buffer whenever we record a new gradient.

with autograd.record():
  y = x.sum()
y.backward()
x.grad # Overwritten by the newly calculated gradient

array([1., 1., 1., 1.])

x_grad == 4 * x

Array([ True, True, True, True], dtype=bool)

y = lambda x: x.sum()
grad(y)(x)

Array([1., 1., 1., 1.], dtype=float32)

x_grad == 4 * x


Now let’s calculate another function of x and take its gradient. Note that TensorFlow resets the gradient buffer whenever we record a new gradient.

with tf.GradientTape() as t:
  y = tf.reduce_sum(x)
t.gradient(y, x) # Overwritten by the newly calculated gradient


2.5.2. 非標(biāo)量變量的后向

當(dāng)y是向量時(shí),y關(guān)于向量的導(dǎo)數(shù)最自然的解釋是稱(chēng)為雅可比x矩陣的矩陣,其中包含關(guān)于每個(gè)分量的每個(gè)分量的偏導(dǎo)數(shù)。同樣,對(duì)于高階和,微分結(jié)果可能是更高階的張量。yxyx

y 雖然 Jacobian 矩陣確實(shí)出現(xiàn)在一些高級(jí)機(jī)器學(xué)習(xí)技術(shù)中,但更常見(jiàn)的是,我們希望將 的每個(gè)分量相對(duì)于完整向量 的梯度求和x,從而產(chǎn)生與 形狀相同的向量x。例如,我們通常有一個(gè)向量表示我們的損失函數(shù)的值,分別為一批訓(xùn)練示例中的每個(gè)示例計(jì)算。在這里,我們只想總結(jié)為每個(gè)示例單獨(dú)計(jì)算的梯度。

由于深度學(xué)習(xí)框架在解釋非標(biāo)量張量梯度的方式上有所不同,因此 PyTorch 采取了一些措施來(lái)避免混淆。調(diào)用backward非標(biāo)量會(huì)引發(fā)錯(cuò)誤,除非我們告訴 PyTorch 如何將對(duì)象縮減為標(biāo)量。更正式地說(shuō),我們需要提供一些向量v這樣backward會(huì)計(jì)算v??xy而不是?xy. 下一部分可能令人困惑,但出于稍后會(huì)變得清楚的原因,這個(gè)論點(diǎn)(代表v) 被命名為gradient。更詳細(xì)的描述見(jiàn)楊章的Medium帖子。

x.grad.zero_()
y = x * x
y.backward(gradient=torch.ones(len(y))) # Faster: y.sum().backward()
x.grad

tensor([0., 2., 4., 6.])

MXNet handles this problem by reducing all tensors to scalars by summing before computing a gradient. In other words, rather than returning the Jacobian ?xy, it returns the gradient of the sum ?x∑iyi.

with autograd.record():
  y = x * x
y.backward()
x.grad # Equals the gradient of y = sum(x * x)

array([0., 2., 4., 6.])

y = lambda x: x * x
# grad is only defined for scalar output functions
grad(lambda x: y(x).sum())(x)

Array([0., 2., 4., 6.], dtype=float32)

By default, TensorFlow returns the gradient of the sum. In other words, rather than returning the Jacobian ?xy, it returns the gradient of the sum ?x∑iyi.

with tf.GradientTape() as t:
  y = x * x
t.gradient(y, x) # Same as y = tf.reduce_sum(x * x)


2.5.3. 分離計(jì)算

有時(shí),我們希望將一些計(jì)算移到記錄的計(jì)算圖之外。例如,假設(shè)我們使用輸入來(lái)創(chuàng)建一些我們不想為其計(jì)算梯度的輔助中間項(xiàng)。在這種情況下,我們需要從最終結(jié)果中分離出相應(yīng)的計(jì)算圖。下面的玩具示例更清楚地說(shuō)明了這一點(diǎn):假設(shè)我們有,但我們想關(guān)注on的直接影響,而不是通過(guò) 傳達(dá)的影響。在這種情況下,我們可以創(chuàng)建一個(gè)新變量 ,該變量具有與 相同的值,但其出處(創(chuàng)建方式)已被清除。因此z = x * yy = x * xxzyuyu圖中沒(méi)有祖先,梯度不會(huì)u流向x. 例如,采用 的梯度將產(chǎn)生結(jié)果,(與 您自 以來(lái)可能預(yù)期的不同)。z = x * ux3 * x * xz = x * x * x

x.grad.zero_()
y = x * x
u = y.detach()
z = u * x

z.sum().backward()
x.grad == u

tensor([True, True, True, True])

with autograd.record():
  y = x * x
  u = y.detach()
  z = u * x
z.backward()
x.grad == u

array([ True, True, True, True])

import jax

y = lambda x: x * x
# jax.lax primitives are Python wrappers around XLA operations
u = jax.lax.stop_gradient(y(x))
z = lambda x: u * x

grad(lambda x: z(x).sum())(x) == y(x)

Array([ True, True, True, True], dtype=bool)

# Set persistent=True to preserve the compute graph.
# This lets us run t.gradient more than once
with tf.GradientTape(persistent=True) as t:
  y = x * x
  u = tf.stop_gradient(y)
  z = u * x

x_grad = t.gradient(z, x)
x_grad == u


請(qǐng)注意,雖然此過(guò)程將y的祖先與 的圖分離z,但導(dǎo)致 的計(jì)算圖仍然存在,因此我們可以計(jì)算關(guān)于y的梯度。yx

x.grad.zero_()
y.sum().backward()
x.grad == 2 * x

tensor([True, True, True, True])

y.backward()
x.grad == 2 * x

array([ True, True, True, True])

grad(lambda x: y(x).sum())(x) == 2 * x

Array([ True, True, True, True], dtype=bool)

t.gradient(y, x) == 2 * x


2.5.4. 漸變和 Python 控制流

到目前為止,我們回顧了從輸入到輸出的路徑通過(guò)諸如. 編程為我們計(jì)算結(jié)果的方式提供了更多的自由。例如,我們可以使它們依賴(lài)于輔助變量或?qū)χ虚g結(jié)果的條件選擇。使用自動(dòng)微分的一個(gè)好處是,即使構(gòu)建函數(shù)的計(jì)算圖需要通過(guò)迷宮般的 Python 控制流(例如,條件、循環(huán)和任意函數(shù)調(diào)用),我們?nèi)匀豢梢杂?jì)算結(jié)果變量的梯度。為了說(shuō)明這一點(diǎn),請(qǐng)考慮以下代碼片段,其中循環(huán)的迭代次數(shù) 和語(yǔ)句的評(píng)估都取決于輸入的值。z = x * x * xwhileifa

def f(a):
  b = a * 2
  while b.norm() < 1000:
    b = b * 2
  if b.sum() > 0:
    c = b
  else:
    c = 100 * b
  return c

def f(a):
  b = a * 2
  while np.linalg.norm(b) < 1000:
    b = b * 2
  if b.sum() > 0:
    c = b
  else:
    c = 100 * b
  return c

def f(a):
  b = a * 2
  while jnp.linalg.norm(b) < 1000:
    b = b * 2
  if b.sum() > 0:
    c = b
  else:
    c = 100 * b
  return c

def f(a):
  b = a * 2
  while tf.norm(b) < 1000:
    b = b * 2
  if tf.reduce_sum(b) > 0:
    c = b
  else:
    c = 100 * b
  return c

下面,我們調(diào)用這個(gè)函數(shù),傳入一個(gè)隨機(jī)值作為輸入。由于輸入是一個(gè)隨機(jī)變量,我們不知道計(jì)算圖將采用什么形式。然而,每當(dāng)我們f(a)對(duì)一個(gè)特定的輸入執(zhí)行時(shí),我們就會(huì)實(shí)現(xiàn)一個(gè)特定的計(jì)算圖并可以隨后運(yùn)行backward。

a = torch.randn(size=(), requires_grad=True)
d = f(a)
d.backward()

a = np.random.normal()
a.attach_grad()
with autograd.record():
  d = f(a)
d.backward()

from jax import random

a = random.normal(random.PRNGKey(1), ())
d = f(a)
d_grad = grad(f)(a)

a = tf.Variable(tf.random.normal(shape=()))
with tf.GradientTape() as t:
  d = f(a)
d_grad = t.gradient(d, a)
d_grad


盡管我們的函數(shù)f出于演示目的有點(diǎn)人為設(shè)計(jì),但它對(duì)輸入的依賴(lài)性非常簡(jiǎn)單:它是具有分段定義比例的線(xiàn)性 函數(shù)。a因此,是一個(gè)包含常量項(xiàng)的向量,此外,需要匹配關(guān)于的梯度。f(a) / af(a) / af(a)a

a.grad == d / a

tensor(True)

a.grad == d / a

array(True)

d_grad == d / a

Array(True, dtype=bool)

d_grad == d / a


動(dòng)態(tài)控制流在深度學(xué)習(xí)中很常見(jiàn)。例如,在處理文本時(shí),計(jì)算圖取決于輸入的長(zhǎng)度。在這些情況下,自動(dòng)微分對(duì)于統(tǒng)計(jì)建模變得至關(guān)重要,因?yàn)椴豢赡芟闰?yàn)地計(jì)算梯度。

2.5.5. 討論

您現(xiàn)在已經(jīng)領(lǐng)略了自動(dòng)微分的威力。用于自動(dòng)和高效計(jì)算導(dǎo)數(shù)的庫(kù)的開(kāi)發(fā)極大地提高了深度學(xué)習(xí)從業(yè)者的生產(chǎn)力,使他們能夠?qū)W⒂诟呒?jí)的問(wèn)題。此外,autograd 允許我們?cè)O(shè)計(jì)大量模型,筆和紙的梯度計(jì)算將非常耗時(shí)。有趣的是,雖然我們使用 autograd 來(lái)優(yōu)化模型(在統(tǒng)計(jì)意義上),但autograd 庫(kù)本身的優(yōu)化(在計(jì)算意義上)是框架設(shè)計(jì)者非常感興趣的一個(gè)豐富主題。在這里,來(lái)自編譯器和圖形操作的工具被用來(lái)以最方便和內(nèi)存效率最高的方式計(jì)算結(jié)果。

現(xiàn)在,試著記住這些基礎(chǔ)知識(shí):(i) 將梯度附加到那些我們想要導(dǎo)數(shù)的變量;(ii) 記錄目標(biāo)值的計(jì)算;(iii) 執(zhí)行反向傳播功能;(iv) 訪問(wèn)生成的梯度。

2.5.6. 練習(xí)

為什么二階導(dǎo)數(shù)的計(jì)算成本比一階導(dǎo)數(shù)高得多?

運(yùn)行反向傳播函數(shù)后,立即再次運(yùn)行它,看看會(huì)發(fā)生什么。為什么?

d在我們計(jì)算關(guān)于 的導(dǎo)數(shù)的控制流示例中 a,如果我們將變量更改a為隨機(jī)向量或矩陣會(huì)發(fā)生什么?此時(shí),計(jì)算的結(jié)果f(a)不再是標(biāo)量。結(jié)果會(huì)怎樣?我們?nèi)绾畏治鲞@個(gè)?

讓f(x)=sin?(x). 繪制圖形f及其衍生物f′. 不要利用這個(gè)事實(shí) f′(x)=cos?(x)而是使用自動(dòng)微分來(lái)獲得結(jié)果。

讓f(x)=((log?x2)?sin?x)+x?1. 寫(xiě)出依賴(lài)圖跟蹤結(jié)果x到f(x).

使用鏈?zhǔn)椒▌t計(jì)算導(dǎo)數(shù)dfdx上述函數(shù),將每個(gè)術(shù)語(yǔ)放在您之前構(gòu)建的依賴(lài)圖上。

給定圖形和中間導(dǎo)數(shù)結(jié)果,您在計(jì)算梯度時(shí)有多種選擇。從開(kāi)始評(píng)估結(jié)果x到f一次來(lái)自f 追溯到x. 路徑從x到f通常稱(chēng)為前向微分,而從 f到x被稱(chēng)為向后微分。

你什么時(shí)候想用前向微分,什么時(shí)候用后向微分?提示:考慮所需的中間數(shù)據(jù)量、并行化步驟的能力以及涉及的矩陣和向量的大小。

聲明:本文內(nèi)容及配圖由入駐作者撰寫(xiě)或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問(wèn)題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • pytorch
    +關(guān)注

    關(guān)注

    2

    文章

    809

    瀏覽量

    13943
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評(píng)論

    相關(guān)推薦
    熱點(diǎn)推薦

    Pytorch自動(dòng)求導(dǎo)示例

    Pytorch自動(dòng)微分的幾個(gè)例子
    發(fā)表于 08-09 11:56

    PyTorch如何入門(mén)

    PyTorch 入門(mén)實(shí)戰(zhàn)(一)——Tensor
    發(fā)表于 06-01 09:58

    通過(guò)Cortex來(lái)非常方便的部署PyTorch模型

    的工作。那么,問(wèn)題是如何將 RoBERTa 部署為一個(gè) JSON API,而不需要手動(dòng)滾動(dòng)所有這些自定義基礎(chǔ)設(shè)施?將 PyTorch 模型與 Cortex 一起投入生產(chǎn)你可以使用 Cortex 自動(dòng)化部署
    發(fā)表于 11-01 15:25

    實(shí)用微分

    實(shí)用微分微分
    發(fā)表于 09-25 14:34 ?844次閱讀
    實(shí)用<b class='flag-5'>微分</b>器

    一篇非常新的介紹PyTorch內(nèi)部機(jī)制的文章

    /pytorch-internals/ 翻譯努力追求通俗、易懂,有些熟知的名詞沒(méi)有進(jìn)行翻譯比如(Tensor, 張量) 部分專(zhuān)有名詞翻譯對(duì)照表如下 英文 譯文 ? ? ? autograde 自動(dòng)微分
    的頭像 發(fā)表于 12-26 10:17 ?2442次閱讀
    一篇非常新的介紹<b class='flag-5'>PyTorch</b>內(nèi)部機(jī)制的文章

    基于PyTorch的深度學(xué)習(xí)入門(mén)教程之PyTorch簡(jiǎn)單知識(shí)

    本文參考PyTorch官網(wǎng)的教程,分為五個(gè)基本模塊來(lái)介紹PyTorch。為了避免文章過(guò)長(zhǎng),這五個(gè)模塊分別在五篇博文中介紹。 Part1:PyTorch簡(jiǎn)單知識(shí) Part2:PyTorch
    的頭像 發(fā)表于 02-16 15:20 ?2503次閱讀

    基于PyTorch的深度學(xué)習(xí)入門(mén)教程之PyTorch自動(dòng)梯度計(jì)算

    本文參考PyTorch官網(wǎng)的教程,分為五個(gè)基本模塊來(lái)介紹PyTorch。為了避免文章過(guò)長(zhǎng),這五個(gè)模塊分別在五篇博文中介紹。 Part1:PyTorch簡(jiǎn)單知識(shí) Part2:PyTorch
    的頭像 發(fā)表于 02-16 15:26 ?2275次閱讀

    基于PyTorch的深度學(xué)習(xí)入門(mén)教程之PyTorch重點(diǎn)綜合實(shí)踐

    前言 PyTorch提供了兩個(gè)主要特性: (1) 一個(gè)n維的Tensor,與numpy相似但是支持GPU運(yùn)算。 (2) 搭建和訓(xùn)練神經(jīng)網(wǎng)絡(luò)的自動(dòng)微分功能。 我們將會(huì)使用一個(gè)全連接的ReLU網(wǎng)絡(luò)作為
    的頭像 發(fā)表于 02-15 10:01 ?2109次閱讀

    PyTorch1.8和Tensorflow2.5該如何選擇?

    自深度學(xué)習(xí)重新獲得公認(rèn)以來(lái),許多機(jī)器學(xué)習(xí)框架層出不窮,爭(zhēng)相成為研究人員以及行業(yè)從業(yè)人員的新寵。從早期的學(xué)術(shù)成果 Caffe、Theano,到獲得龐大工業(yè)支持的 PyTorch、TensorFlow
    的頭像 發(fā)表于 07-09 10:33 ?1837次閱讀

    PyTorch 的 Autograd 機(jī)制和使用

    PyTorch 作為一個(gè)深度學(xué)習(xí)平臺(tái),在深度學(xué)習(xí)任務(wù)中比 NumPy 這個(gè)科學(xué)計(jì)算庫(kù)強(qiáng)在哪里呢?我覺(jué)得一是 PyTorch 提供了自動(dòng)求導(dǎo)機(jī)制,二是對(duì) GPU 的支持。由此可見(jiàn),自動(dòng)
    的頭像 發(fā)表于 08-15 09:37 ?1346次閱讀

    PyTorch教程2.5自動(dòng)微分

    電子發(fā)燒友網(wǎng)站提供《PyTorch教程2.5自動(dòng)微分.pdf》資料免費(fèi)下載
    發(fā)表于 06-05 11:38 ?0次下載
    <b class='flag-5'>PyTorch</b>教程<b class='flag-5'>2.5</b>之<b class='flag-5'>自動(dòng)</b><b class='flag-5'>微分</b>

    PyTorch教程13.3之自動(dòng)并行

    電子發(fā)燒友網(wǎng)站提供《PyTorch教程13.3之自動(dòng)并行.pdf》資料免費(fèi)下載
    發(fā)表于 06-05 14:47 ?0次下載
    <b class='flag-5'>PyTorch</b>教程13.3之<b class='flag-5'>自動(dòng)</b>并行

    PyTorch的介紹與使用案例

    學(xué)習(xí)領(lǐng)域的一個(gè)重要工具。PyTorch底層由C++實(shí)現(xiàn),提供了豐富的API接口,使得開(kāi)發(fā)者能夠高效地構(gòu)建和訓(xùn)練神經(jīng)網(wǎng)絡(luò)模型。PyTorch不僅支持動(dòng)態(tài)計(jì)算圖,還提供了強(qiáng)大的自動(dòng)微分系統(tǒng)
    的頭像 發(fā)表于 07-10 14:19 ?912次閱讀

    pytorch怎么在pycharm中運(yùn)行

    第一部分:PyTorch和PyCharm的安裝 1.1 安裝PyTorch PyTorch是一個(gè)開(kāi)源的機(jī)器學(xué)習(xí)庫(kù),用于構(gòu)建和訓(xùn)練神經(jīng)網(wǎng)絡(luò)。要在PyCharm中使用PyTorch,首先需
    的頭像 發(fā)表于 08-01 16:22 ?2515次閱讀

    如何使用 PyTorch 進(jìn)行強(qiáng)化學(xué)習(xí)

    的計(jì)算圖和自動(dòng)微分功能,非常適合實(shí)現(xiàn)復(fù)雜的強(qiáng)化學(xué)習(xí)算法。 1. 環(huán)境(Environment) 在強(qiáng)化學(xué)習(xí)中,環(huán)境是一個(gè)抽象的概念,它定義了智能體(agent)可以執(zhí)行的動(dòng)作(actions)、觀察到
    的頭像 發(fā)表于 11-05 17:34 ?1036次閱讀