在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

一文搞清楚神經網絡

深度學習自然語言處理 ? 來源:深度學習自然語言處理 ? 作者:艾春輝 ? 2020-11-02 15:32 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

Neural Networks

The structure of the neural network

A neuron can be a binary logistic regression unit

公式形式:

b: We can have an “always on” feature, which gives a class prior, or separate it out, as a bias term------b我們常常認為是偏置

A neural network = running several logistic regressions at the same time

單層神經網絡

我們輸入一個向量并且通過一系列的邏輯回歸函數,我們可以得到一個輸出向量,但是我們不需要提前決定,邏輯回歸試圖預測的向量是什么

多層神經網絡

我們可以通過另外一個logistic回歸函數,損失函數將指導中間變量是什么,為了更好的預測下一層的目標。

Matrix notation for a layer--矩陣表示

for example:

我們有:

總結:

f的運算:

非線性的f的必須

重要性:

沒有非線性的激活函數,深度神經網絡無法做比線性變換更復雜的運算

多個線性的神經網絡層相當于一個簡單的線性變換:$W_1W_2x=Wx$

如果采用更多的非線性激活函數,它們可以擬合更復雜的函數

命名主體識別Named Entity Recognition (NER)

The task: findand classifynames in text, for example:

Possible purposes:

Tracking mentions of particular entities in documents---跟蹤文檔中特殊的實體

For question answering, answers are usually named entities------回答一些關于命名主體識別的問題

A lot of wanted information is really associations between named entities---抽取命名主體之間關系

The same techniques can be extended to other slot-filling classifications----可以擴展到分類任務

Why might NER be hard?

實體的邊界很難計算

很難指導某個物體是否是一個實體

很難知道未知/新奇實體的類別

很難識別實體---當實體是模糊的,并且依賴于上下文

Binary word window classification ---小窗口上下文文本分類器

問題:

in general,很少對單個單詞進行分類

ambiguity arise in context,一詞多義的問題

example1:auto-antonyms

"To sanction" can mean "to permit" or "to punish”

"To seed" can mean "to place seeds" or "to remove seeds"

example2:resolving linking of ambiguous named entities

Paris ->Paris, France vs. Paris Hilton vs. Paris, Texas

Hathaway ->Berkshire Hathaway vs. Anne Hathaway

Window classification: Softmax

Idea: classify a word in its context window of neighboring words---在相鄰詞的上下文窗口對一個詞進行分類

A simple way to classify a word in context might be to average the word vectors in a window and to classify the average vector ---一個簡單方法是對上下文的所有詞向量去平均,但是這個方法會丟失位置信息

另一種方法: Train softmaxclassifier to classify a center word by taking concatenation of word vectors surrounding it in a window---將上下文所有單詞的詞向量串聯起來

for example: Classify “Paris” in the context of this sentence with window length 2

Resulting vector $x_{window}=xvarepsilon R^{5d}$一個列向量 然后通過softmax分類器

Binary classification with unnormalizedscores ---給分類的結果一個非標準化分數

之前的例子中:

假設我們需要確認一個中心詞是否是一個地點

和word2vec類似,我們遍歷語料庫的所有位置,但是這一次,它只能在一些地方得到高分

the positions that have an actual NER Location in their center are “true” positions and get a high score ---它們中符合標準的會獲得最高分

Neural Network Feed-forward Computation

采用神經網絡激活函數a簡單的給出一個非標準化分數

我們采用一個3層的神經網絡計算得分

s = score("museums in Paris are amazing”)

Main intuition for extra layer

中間層的作用學習的是輸入詞向量的非線性交互----Example: only if “museums”is first vector should it matter that “in”is in the second position

The max-margin loss

Idea for training objective: Make true window’s score larger and corrupt window’s score lower (until they’re good enough)---訓練思路,讓真實窗口的準確率提高,讓干擾窗口的得分降低

s = score(museums in Paris are amazing)

最小化

這是不可微分,但是是連續的,所以我們可以采用sgd算法進行優化

Each window with an NER location at its center should have a score +1 higher than any window without a location at its center -----每個中心有ner位置的窗口得分應該比中心沒有位置的窗口高1分

For full objective function: Sample several corrupt windows per true one. Sum over all training windows---使用類似于負采樣的方法,為真實窗口采樣幾個錯誤窗口

矩陣求導---不詳細推導

Example Jacobian: Elementwise activation Function

多元求導的例子

針對我們的公式 進行求導換算:

在上面式子中,我們通過鏈式法則可以得出

note: Neural Networks, Backpropagation

Neural Networks: Foundations

A neuron

A neuron is a generic computational unit that takes n inputs and produces a single output. What differentiates the outputs of different neurons is their parameters (also referred to as their weights). -----神經元作用 ? ? 通過圖形可視化上面公式: ?

我們可以看到,神經元是可以允許非線性在網絡中積累的次數之一

A single layer of neurons

我們將單個神經元的思想擴展到多個神經元,考慮輸入x作為多個這樣的神經元輸入

If we refer to the different neurons’ weights as ?and the biases as, we can say the respective activations are : ?

公式簡化 ? 我們可以縮放成: z=Wx+b ? 激活函數變化為: ?

feed-forward computation

首先我們考慮一個nlp中命名實體識別問題作為例子: "Museums in Paris are amazing" 我們想判別中心詞Paris是不是命名主體。在這種情況下,我們很可能不僅想要捕捉窗口中單詞向量,還想要捕捉單詞間的一些其他交互,方便我們分類。For instance, maybe it should matter that "Museums" is the ?rst word only if "in" is the second word. --上面可能存在順序的約束的問題。所以這樣的非線性決策通常不能被直接輸入softmax,而是需要一個中間層進行score。因此我們使用另一個矩陣與激活輸出計算得到的歸一化得分用于分類任務。 ? 這里的f代表的是激活函數 ?

Analysis of Dimensions: If we represent each word using a 4 dimensional word vector and we use a 5-word window as input (as in the above example), then the input . If we use 8 sigmoid units in the hidden layer and generate 1 score output from the activations, then

Maximum Margin Objective Function

我們采用:Maximum Margin Objective Function(最大間隔目標函數),使得保證對‘真’的數據的可能性比‘假’數據的可能性要高

定義符號:Using the previous example, if we call the score computed for the "true" labeled window "Museums in Paris are amazing" as S and the score computed for the "false" labeled window "Not all museums in Paris" as Sc (subscripted as c to signify that the window is "corrupt"). ---正確窗口S,錯誤窗口Sc

隨后,我們目標函數最大化S-Sc或者最小化Sc-S.然而,我們修改目標函數來保證誤差在Sc>S的時候在進行計算。這么做的目的是我們只在關心‘真’數據的得分高于‘假’數據的得分,其他不是很重要。因此,誤差Sc>S時候存在為Sc-S,反之不存在,即為0。所以我們的優化目標是:

However, the above optimization objective is risky in the sense that it does not attempt to create a margin of safety. We would want the "true" labeled data point to score higher than the "false" labeled data point by some positive margin ?. In other words, we would want error to be calculated if (s?sc< ?) and not just when (s?sc?< 0). Thus, we modify the optimization objective: ----上面的優化目標函數是存在風險的,它不能創造一個比較安全的間隔,所以我們希望存在一個這樣的間隔,并且這個間隔需要大于0 ?

We can scale this margin such that it is ? = 1 and let the other parameters in the optimization problem adapt to this without any change in performance.-----有希望了解的可以看svm的推導,這里的意思是說,我們把間隔設置為1,這樣我們可以讓其他參數在優化過程中自動進行調整,并不會影響模型的表現

梯度更新

方向傳播是一種利用鏈式法則來計算模型上任意參數的損失梯度的方法

1. ?is an input to the neural network. ---輸入 2. s is the output of the neural network.---輸出 3. ?Each layer (including the input and output layers) has neurons which receive an input and produce an output. The j-th neuron of layer k receives the scalar inputand produces the scalar activation output---每層中的神經元,上角標是層數,下角標的神經元位置 4. We will call the backpropagated error calculated atas. ---定義z的反向傳播誤差 5. Layer 1 refers to the input layer and not the ?rst hidden layer. ----輸入層不是隱藏層 6.is the transfer matrix that maps the output from the k-th layer to the input to the (k+1)-th -----轉移矩陣

定義:

開始反向傳播

現在開始反向傳播:假設損失函數 ?為正值, 我們想更新參數, ?我們看到 只參與了 ? ?和 ? ?的計算。這點對于理解反向傳搖是非常重要的一一反向傳搖的梯度只受它們所貢獻的值的影響。 在隨后的前向計算中和 ?相乘計算得分。我們可以從最大間隔損失看到: ?

我們只分析

其中, 指輸入層的輸入。我們可以看到梯度計算最后可以簡化為, ?其中 ?本質上是第 2 層中第 ?i ?個神經元反向傳播的誤差。? ?與 ?Wij ?相乘的結果, 輸入第 2 層中第 ?i ?個神經元中。

Training with Backpropagation – Vectorized

對更定的參數 , ?我們知道它的誤差梯度是 ,其中 ?? 是將 ? ?映射到 ? ?的矩 陣。因此我們可以確定整個矩陣 ? ?的梯度誤差為:

因此我們可以將整個矩陣形式的梯度寫為在矩陣中反向傳播的誤差向量和前向激活輸出的外積,并且對于誤差的估算: 其中代表矩陣中每個元素相乘

Neural Networks: Tips and Tricks

Gradient Check

Given a model with parameter vector θ and loss function J, the numerical gradient around θiis simply given by centered difference formula:

其實就是一個梯度的估計

Now, a natural question you might ask is, if this method is so precise, why do we not use it to compute all of our network gradients instead of applying back-propagation? The simple answer, as hinted earlier, is inef?ciency – recall that every time we want to compute the gradient with respect to an element, we need to make two forward passes through the network, which will be computationally expensive. Furthermore, many large-scale neural networks can contain millions of parameters, and computing two passes per parameter is clearly not optimal. -----雖然上面的梯度估計公式很有效,但是這僅僅是隨機檢測我們梯度是否正確的方法。我們最有效的并且最實用(運算效率最高的)算法就是反向傳播算法

Regularization ---正則化

As with many machine learning models, neural networks are highly prone to over?tting, where a model is able to obtain near perfect performance on the training dataset, but loses the ability to generalize to unseen data. ----和很多機器學習模型一樣,神經網絡也會陷入過擬合,這回讓它無法泛化到測試集上。一個常見的解決過擬合的問題就是采用L2正則化(只需要給損失函數J添加一個正則項),改進的損失函數

對上面公式的參數解釋,λ是一個超參數,控制正則項的權值大小,第i層的權值矩陣的Froenius范數:Forenius范數=矩陣中每個元素的平方求和在開根號,

正則項的作用: what regularization is essentially doing is penalizing weights for being too large while optimizing over the original cost function---在優化損失函數的時候,懲罰數值太大的權值,讓權值分配更均勻,防止出現權值過大的情況

Due to the quadratic nature of the Frobenius norm (which computes the sum of the squared elements of a matrix), L2 regularization effectively reduces the ?exibility of the model and thereby reduces the over?tting phenomenon. Imposing such a constraint can also be interpreted as the prior Bayesian belief that the optimal weights are close to zero – how close depends on the value of λ.-----因為正則化有一個二次項的存在,這有利有弊,它會降低模型的靈活性但是也會降低過擬合的可能性。在貝葉斯學說的認為下,正則項可以優化權值并且使得其接近0,但是這個取決于你的一個λ值的大小

Too high a value of λ causes most of the weights to be set too close to 0, and the model does not learn anything meaningful from the training data, often obtaining poor accuracy on training, validation, and testing sets. ---λ取值要合適

為什么偏置沒有正則項

正則化的目的是為了防止過擬合,但是過擬合的表現形式是模型對于輸入的微小變化產生了巨大差異,這主要是因為W的原因,有些w的參數過大。但是b是不背鍋的,偏置b對于輸入的改變是不敏感的,不管輸入改變大還是小。

Dropout---部分參數拋棄運算

the idea is simple yet effective – during training, we will randomly “drop” with some probability (1?p) a subset of neurons during each forward/backward pass (or equivalently, we will keep alive each neuron with a probability p). Then, during testing, we will use the full network to compute our predictions. The result is that the network typically learns more meaningful information from the data, is less likely to over?t, and usually obtains higher performance overall on the task at hand. One intuitive reason why this technique should be so effective is that what dropout is doing is essentially doing is training exponentially many smaller networks at once and averaging over their predictions.---------dropout的思想就是在每次前向傳播或者反向傳播的時候我們按照一定的概率(1-P)凍結神經元,但是剩下概率為p的神經元是激活的,然后在測試階段,我們使用所有的神經元。使用dropout的網絡可以從數據中學到更多的知識

However, a key subtlety is that in order for dropout to work effectively, the expected output of a neuron during testing should be approximately the same as it was during training – else the magnitude of the outputs could be radically different, and the behavior of the network is no longer well-de?ned. Thus, we must typically divide the outputs of each neuron during testing by a certain value --------為了使得的dropout能夠有效,測試階段的神經元的預期輸出應該和訓練階段大致相同---否則輸出的大小存在很大差異,所以我們通常需要在測試階段將每個神經元的輸出除以P(P是存活神經元的概率)

Parameter Initialization--參數初始化

A key step towards achieving superlative performance with a neural network is initializing the parameters in a reasonable way. A good starting strategy is to initialize the weights to small random numbers normally distributed around 0 ---通常我們的權值隨機初始化在0附近 是W(fan-in)的輸入單元數,是W(fan-out)的輸出單元數

加餐:優化算法----此內容來源于datawhale'顏值擔當'

基于歷史的動態梯度優化算法結構

SGD

Momentum

NAG

AdaGrad

AdaDelta

Adam

Nadam

責任編輯:xj

原文標題:【CS224N筆記】一文詳解神經網絡來龍去脈

文章出處:【微信公眾號:深度學習自然語言處理】歡迎添加關注!文章轉載請注明出處。

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 神經網絡
    +關注

    關注

    42

    文章

    4814

    瀏覽量

    103432
  • 函數
    +關注

    關注

    3

    文章

    4379

    瀏覽量

    64739
  • 神經元
    +關注

    關注

    1

    文章

    368

    瀏覽量

    18819

原文標題:【CS224N筆記】一文詳解神經網絡來龍去脈

文章出處:【微信號:zenRRan,微信公眾號:深度學習自然語言處理】歡迎添加關注!文章轉載請注明出處。

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

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    BP神經網絡與卷積神經網絡的比較

    BP神經網絡與卷積神經網絡在多個方面存在顯著差異,以下是對兩者的比較: 、結構特點 BP神經網絡 : BP神經網絡
    的頭像 發表于 02-12 15:53 ?639次閱讀

    什么是BP神經網絡的反向傳播算法

    BP神經網絡的反向傳播算法(Backpropagation Algorithm)是種用于訓練神經網絡的有效方法。以下是關于BP神經網絡的反向傳播算法的介紹:
    的頭像 發表于 02-12 15:18 ?749次閱讀

    BP神經網絡與深度學習的關系

    BP神經網絡與深度學習之間存在著密切的關系,以下是對它們之間關系的介紹: 、BP神經網絡的基本概念 BP神經網絡,即反向傳播神經網絡(Ba
    的頭像 發表于 02-12 15:15 ?841次閱讀

    人工神經網絡的原理和多種神經網絡架構方法

    在上篇文章中,我們介紹了傳統機器學習的基礎知識和多種算法。在本文中,我們會介紹人工神經網絡的原理和多種神經網絡架構方法,供各位老師選擇。 01 人工神經網絡 ? 人工
    的頭像 發表于 01-09 10:24 ?1174次閱讀
    人工<b class='flag-5'>神經網絡</b>的原理和多種<b class='flag-5'>神經網絡</b>架構方法

    詳解物理信息神經網絡

    物理信息神經網絡 (PINN) 是神經網絡,它將微分方程描述的物理定律納入其損失函數中,以引導學習過程得出更符合基本物理定律的解。
    的頭像 發表于 12-05 16:50 ?8038次閱讀
    <b class='flag-5'>一</b><b class='flag-5'>文</b>詳解物理信息<b class='flag-5'>神經網絡</b>

    卷積神經網絡與傳統神經網絡的比較

    神經網絡,也稱為全連接神經網絡(Fully Connected Neural Networks,FCNs),其特點是每層的每個神經元都與下
    的頭像 發表于 11-15 14:53 ?1837次閱讀

    RNN模型與傳統神經網絡的區別

    神經網絡是機器學習領域中的種強大工具,它們能夠模擬人腦處理信息的方式。隨著技術的發展,神經網絡的類型也在不斷增加,其中循環神經網絡(RNN)和傳統
    的頭像 發表于 11-15 09:42 ?1113次閱讀

    LSTM神經網絡的結構與工作機制

    LSTM(Long Short-Term Memory,長短期記憶)神經網絡種特殊的循環神經網絡(RNN),設計用于解決長期依賴問題,特別是在處理時間序列數據時表現出色。以下是LSTM神經
    的頭像 發表于 11-13 10:05 ?1614次閱讀

    matlab 神經網絡 數學建模數值分析

    matlab神經網絡 數學建模數值分析 精通的可以討論下
    發表于 09-18 15:14

    如何編寫個BP神經網絡

    BP(反向傳播)神經網絡種多層前饋神經網絡,它通過反向傳播算法來訓練網絡中的權重和偏置,以最小化輸出誤差。BP神經網絡的核心在于其前向傳
    的頭像 發表于 07-11 16:44 ?1103次閱讀

    神經網絡辨識模型具有什么特點

    神經網絡辨識模型是種基于人工神經網絡的系統辨識方法,它具有以下特點: 非線性映射能力 :神經網絡能夠處理非線性問題,可以很好地擬合復雜的非線性系統。 泛化能力 :
    的頭像 發表于 07-11 11:12 ?871次閱讀

    怎么對神經網絡重新訓練

    重新訓練神經網絡個復雜的過程,涉及到多個步驟和考慮因素。 引言 神經網絡種強大的機器學習模型,廣泛應用于圖像識別、自然語言處理、語音識別等領域。然而,隨著時間的推移,數據分布可
    的頭像 發表于 07-11 10:25 ?853次閱讀

    遞歸神經網絡和循環神經網絡的模型結構

    遞歸神經網絡種旨在處理分層結構的神經網絡,使其特別適合涉及樹狀或嵌套數據的任務。這些網絡明確地模擬了層次結構中的關系和依賴關系,例如語言中的句法結構或圖像中的層次表示。它使用遞歸操
    的頭像 發表于 07-10 17:21 ?1274次閱讀
    遞歸<b class='flag-5'>神經網絡</b>和循環<b class='flag-5'>神經網絡</b>的模型結構

    BP神經網絡和卷積神經網絡的關系

    BP神經網絡(Backpropagation Neural Network)和卷積神經網絡(Convolutional Neural Network,簡稱CNN)是兩種在人工智能和機器學習領域
    的頭像 發表于 07-10 15:24 ?2439次閱讀

    BP神經網絡和人工神經網絡的區別

    BP神經網絡和人工神經網絡(Artificial Neural Networks,簡稱ANNs)之間的關系與區別,是神經網絡領域中個基礎且重要的話題。本文將從定義、結構、算法、應用及
    的頭像 發表于 07-10 15:20 ?2267次閱讀
    主站蜘蛛池模板: 亚洲福利视频网址 | 五月天婷五月天综合网在线 | 天堂资源在线中文 | 美女黄色一级毛片 | 日本三级视频 | yy6080亚洲半夜理论一级毛片 | 成人免费精品视频 | 国产婷婷| 欧美日韩国产成人精品 | 精品欧美一区二区三区在线观看 | 国产精品护士 | 久久99精品国产麻豆宅宅 | 九九热在线视频观看这里只有精品 | 午夜爽爽爽 | 屁股趴过来欠打高h | 亚洲电影在线看 | 三级精品视频在线播放 | 377p亚洲欧洲日本大胆色噜噜 | 天天干天天操天天舔 | 三级欧美视频 | 日本一卡二卡3卡四卡网站精品 | 国产丝袜va丝袜老师 | 在线播放一区二区精品产 | 2019偷偷狠狠的日日 | 四虎国产精品免费观看 | 粉嫩尤物在线456 | 5g影院欧美成人免费 | 国产精品福利一区 | 国产小视频在线 | 中文字幕在线第一页 | 新版天堂中文资源官网 | 亚洲色图日韩精品 | 天堂伊人| 天天在线天天在线天天影视 | 中国成人在线视频 | 男子扒开美女尿口做羞羞的事 | 白丝丝袜高跟国产在线视频 | 国产在线色| 免费黄色大片在线观看 | 色色色色色色网 | 欧美18xxoovideos|