RL【3】:Bellman Optimality Equation

系列文章目錄


文章目錄

  • 系列文章目錄
  • 前言
  • Definition of optimal policy
  • Bellman optimality equation
    • Introduction
    • Maximization on the right-hand side
    • Contraction mapping theorem
    • Solution
    • Optimality
  • Analyzing optimal policies
  • 總結


前言

本系列文章主要用于記錄 B站 趙世鈺老師的【強化學習的數學原理】的學習筆記,關于趙老師課程的具體內容,可以移步:
B站視頻:【【強化學習的數學原理】課程:從零開始到透徹理解(完結)】
GitHub 課程資料:Book-Mathematical-Foundation-of-Reinforcement-Learning


Definition of optimal policy

The state value could be used to evaluate if a policy is good or not: if

vπ1(s)≥vπ2(s),?s∈Sv_{\pi_1}(s) \geq v_{\pi_2}(s), \quad \forall s \in \mathcal{S}vπ1??(s)vπ2??(s),?sS

then π1\pi_1π1? is “better” than π2\pi_2π2?.

A policy π?\pi^*π? is optimal if

vπ?(s)≥vπ(s),?s∈S,?π.v_{\pi^*}(s) \geq v_\pi(s), \quad \forall s \in \mathcal{S}, \; \forall \pi.vπ??(s)vπ?(s),?sS,?π.


Bellman optimality equation

Introduction

Bellman optimality equation (elementwise form):

v(s)=max?π∑aπ(a∣s)(∑rp(r∣s,a)r+γ∑s′p(s′∣s,a)v(s′)),?s∈Sv(s) = \max_{\pi} \sum_a \pi(a \mid s) \left( \sum_r p(r \mid s,a) r + \gamma \sum_{s'} p(s' \mid s,a) v(s') \right), \quad \forall s \in \mathcal{S}v(s)=maxπ?a?π(as)(r?p(rs,a)r+γs?p(ss,a)v(s)),?sS

=max?π∑aπ(a∣s)q(s,a),s∈S= \max_{\pi} \sum_a \pi(a \mid s) q(s,a), \quad s \in \mathcal{S}=maxπ?a?π(as)q(s,a),sS

Remarks:

  • p(r∣s,a),p(s′∣s,a)p(r \mid s,a), p(s' \mid s,a)p(rs,a),p(ss,a) are known.
  • v(s),v(s′)v(s), v(s')v(s),v(s) are unknown and to be calculated.
  • π(s)\pi(s)π(s) is known!

結合 Bellman 方程依賴于已知策略,解釋為什么在 Bellman 最優性方程 里要取 max?π\max_\pimaxπ?,以及它和最優策略 π?\pi^*π? 的關系

  1. 回顧:Bellman 方程(依賴已知策略)

    對于一個固定的策略 π\piπ,狀態價值函數定義為:

    vπ(s)=∑aπ(a∣s)[∑rp(r∣s,a)r+γ∑s’p(s’∣s,a)vπ(s’)]v_\pi(s) = \sum_a \pi(a \mid s) \Bigg[ \sum_r p(r \mid s,a) r + \gamma \sum_{s’} p(s’ \mid s,a) v_\pi(s’) \Bigg]vπ?(s)=a?π(as)[r?p(rs,a)r+γs?p(ss,a)vπ?(s)]

    • 這里 π(a∣s)\pi(a|s)π(as)已知的動作分布,所以 Bellman 方程在這種情況下是 策略評估 (policy evaluation) 工具。
      • 策略 = 對每個狀態 sss,給所有可能動作 aaa 分配概率,即一個策略對應了一組“所有狀態的動作概率分布”
      • 不同策略對應的就是 不同的動作概率分布集合
        • 策略 π1\pi_1π1?

          在狀態 sss,可能給動作 a1a_1a1? 的概率高一些,給動作 a2a_2a2? 的概率低一些。

        • 策略 π2\pi_2π2?

          在相同狀態 sss,可能恰好相反,給 a1a_1a1? 的概率低,給 a2a_2a2? 的概率高。

  2. 從策略依賴到最優性

    • 如果我們不想只評估一個具體策略,而是想找到 最優策略,那就需要考慮:對于每個狀態 sss,什么樣的動作選擇(或策略)能最大化長期回報?

    • 于是,狀態價值的定義變成:

      v?(s)=max?πvπ(s),?s∈Sv^*(s) = \max_\pi v_\pi(s), \quad \forall s \in \mathcal{S}v?(s)=maxπ?vπ?(s),?sS

    • 這里的 max?π\max_\pimaxπ? 表示:在所有可能的策略中,找到一個能使價值函數最大的策略。

  3. Bellman 最優性方程

    • max?π\max_\pimaxπ? 引入 Bellman 方程,得到:

      v(s)=max?a[∑rp(r∣s,a)r+γ∑s’p(s’∣s,a)v(s’)]v^(s) = \max_a \Bigg[ \sum_r p(r \mid s,a) r + \gamma \sum_{s’} p(s’ \mid s,a) v^(s’) \Bigg]v(s)=maxa?[r?p(rs,a)r+γs?p(ss,a)v(s)]

    • 關鍵點:

      • 在普通 Bellman 方程里:π(a∣s)\pi(a|s)π(as) 是已知的分布。
      • 在 Bellman 最優性方程里:我們不固定策略,而是 直接在動作層面取最大化,等價于“選擇最優動作”。
      • 因此,最優價值函數 v?(s)v^*(s)v?(s) 不再依賴于某個具體的 π\piπ,而是內含了 策略優化的過程
  4. 和最優策略 π?\pi^*π? 的關系

    • 定義:

      π(s)=arg?max?a[∑rp(r∣s,a)r+γ∑s’p(s’∣s,a)v(s’)]\pi^(s) = \arg\max_a \Bigg[ \sum_r p(r \mid s,a) r + \gamma \sum_{s’} p(s’ \mid s,a) v^(s’) \Bigg]π(s)=argmaxa?[r?p(rs,a)r+γs?p(ss,a)v(s)]

      即最優策略就是在每個狀態下選擇能使未來回報最大的動作。

    • 換句話說:

      • 普通 Bellman 方程 = 已知策略的價值評估
      • Bellman 最優性方程 = 在所有策略中選擇最優的價值函數,從而定義了最優策略。

Bellman optimality equation (matrix-vector form):

v=max?π(rπ+γPπv)v = \max_\pi (r_\pi + \gamma P_\pi v)v=maxπ?(rπ?+γPπ?v)

where the elements corresponding to sss or s′s's are

[rπ]s?∑aπ(a∣s)∑rp(r∣s,a)r,[r_\pi]_s \triangleq \sum_a \pi(a \mid s) \sum_r p(r \mid s,a) r,[rπ?]s??a?π(as)r?p(rs,a)r,

[Pπ]s,s′=p(s′∣s)?∑aπ(a∣s)∑s′p(s′∣s,a)[P_\pi]{s,s'} = p(s' \mid s) \triangleq \sum_a \pi(a \mid s) \sum{s'} p(s' \mid s,a)[Pπ?]s,s=p(ss)?a?π(as)sp(ss,a)

Here max?π\max_\pimaxπ? is performed elementwise.

Maximization on the right-hand side

Solve the Bellman optimality equation

必須先考慮右邊的式子,即先有某個最優策略 π\piπ,然后才有最優的狀態價值 v(s)v(s)v(s)

  • elementwise form

    v(s)=max?π∑aπ(a∣s)(∑rp(r∣s,a)r+γ∑s′p(s′∣s,a)v(s′)),?s∈Sv(s) = \max_{\pi} \sum_a \pi(a \mid s) \left( \sum_r p(r \mid s,a) r + \gamma \sum_{s'} p(s' \mid s,a) v(s') \right), \quad \forall s \in \mathcal{S}v(s)=maxπ?a?π(as)(r?p(rs,a)r+γs?p(ss,a)v(s)),?sS

    • Fix v′(s)v'(s)v(s) first and solve π\piπ:

      v(s)=max?π∑aπ(a∣s)q(s,a)v(s) = \max_\pi \sum_a \pi(a \mid s) q(s,a)v(s)=maxπ?a?π(as)q(s,a)

    • Inspired by the above example, considering that ∑aπ(a∣s)=1\sum_a \pi(a \mid s) = 1a?π(as)=1, we have

      max?π∑aπ(a∣s)q(s,a)=max?a∈A(s)q(s,a),\max_\pi \sum_a \pi(a \mid s) q(s,a) = \max_{a \in \mathcal{A}(s)} q(s,a),maxπ?a?π(as)q(s,a)=maxaA(s)?q(s,a),

    • where the optimality is achieved when

      π(a∣s)={1,a=a?0,a≠a?\pi(a \mid s) = \begin{cases} 1, & a = a^* \\ 0, & a \neq a^* \end{cases}π(as)={1,0,?a=a?a=a??

    • where a?=arg?max?aq(s,a)a^* = \arg\max_a q(s,a)a?=argmaxa?q(s,a).

  • matrix-vector form

    v=max?π(rπ+γPπv)v = \max_\pi (r_\pi + \gamma P_\pi v)v=maxπ?(rπ?+γPπ?v)

    • Let

      f(v):=max?π(rπ+γPπv).f(v) := \max_\pi (r_\pi + \gamma P_\pi v).f(v):=maxπ?(rπ?+γPπ?v).

    • Then, the Bellman optimality equation becomes

      v=f(v)v = f(v)v=f(v)

    • where

      [f(v)]s=max?π∑aπ(a∣s)q(s,a),s∈S.[f(v)]s = \max\pi \sum_a \pi(a \mid s) q(s,a), \quad s \in \mathcal{S}.[f(v)]s=maxπa?π(as)q(s,a),sS.

Contraction mapping theorem

Fixed point:

x∈Xx \in XxX is a fixed point of f:X→Xf : X \to Xf:XX if f(x)=xf(x) = xf(x)=x

Contraction mapping (or contractive function):

fff is a contraction mapping if ∥f(x1)?f(x2)∥≤γ∥x1?x2∥\| f(x_1) - f(x_2) \| \leq \gamma \| x_1 - x_2 \|f(x1?)?f(x2?)γx1??x2?, where γ∈(0,1)\gamma \in (0,1)γ(0,1).

  • γ\gammaγ must be strictly less than 111 so that many limits such as γk→0\gamma^k \to 0γk0 as k→∞k \to \inftyk hold.
  • Here ∥?∥\| \cdot \|? can be any vector norm.

Contraction mapping theorem

For any equation that has the form of x=f(x)x = f(x)x=f(x), if fff is a contraction mapping, then

  • Existence: There exists a fixed point x?x^*x? satisfying f(x?)=x?f(x^*) = x^*f(x?)=x?.
  • Uniqueness: The fixed point x?x^*x? is unique.
  • Algorithm: Consider a sequence {xk}\{x_k\}{xk?} where xk+1=f(xk)x_{k+1} = f(x_k)xk+1?=f(xk?), then xk→x?x_k \to x^*xk?x? as k→∞k \to \inftyk. Moreover, the convergence rate is exponentially fast.

Solution

Let’s come back to the Bellman optimality equation:

v=f(v)=max?π(rπ+γPπv)v = f(v) = \max_\pi (r_\pi + \gamma P_\pi v)v=f(v)=maxπ?(rπ?+γPπ?v)

Contraction Property:

  • f(v)f(v)f(v) is a contraction mapping satisfying

    ∥f(v1)?f(v2)∥≤γ∥v1?v2∥\| f(v_1) - f(v_2) \| \leq \gamma \| v_1 - v_2 \|f(v1?)?f(v2?)γv1??v2?

  • where γ\gammaγ is the discount rate!

Existence, Uniqueness, and Algorithm:

  • For the BOE v=f(v)=max?π(rπ+γPπv)v = f(v) = \max_\pi (r_\pi + \gamma P_\pi v)v=f(v)=maxπ?(rπ?+γPπ?v), there always exists a solution v?v^*v? and the solution is unique. The solution could be solved iteratively by

    vk+1=f(vk)=max?π(rπ+γPπvk)v_{k+1} = f(v_k) = \max_\pi (r_\pi + \gamma P_\pi v_k)vk+1?=f(vk?)=maxπ?(rπ?+γPπ?vk?)

  • This sequence {vk}\{v_k\}{vk?} converges to v?v^*v? exponentially fast given any initial guess v0v_0v0?. The convergence rate is determined by γ\gammaγ.

Optimality

Suppose v?v^*v? is the solution to the Bellman optimality equation. It satisfies

v?=max?π(rπ+γPπv?)v^* = \max_\pi (r_\pi + \gamma P_\pi v^*)v?=maxπ?(rπ?+γPπ?v?)

Suppose

π?=arg?max?π(rπ+γPπv?)\pi^* = \arg\max_\pi (r_\pi + \gamma P_\pi v^*)π?=argmaxπ?(rπ?+γPπ?v?)

Then

v?=rπ?+γPπ?v?v^* = r_{\pi^*} + \gamma P_{\pi^*} v^*v?=rπ??+γPπ??v?

Therefore, π?\pi^*π? is a policy and v?=vπ?v^* = v_{\pi^*}v?=vπ?? is the corresponding state value.

Policy Optimality

  • Suppose that v?v^*v? is the unique solution to v=max?π(rπ+γPπv),v = \max_\pi (r_\pi + \gamma P_\pi v),v=maxπ?(rπ?+γPπ?v),
    and vπv_\pivπ? is the state value function satisfying vπ=rπ+γPπvπv_\pi = r_\pi + \gamma P_\pi v_\pivπ?=rπ?+γPπ?vπ? for any given policy π\piπ, then

    v≥vπ,?πv^ \geq v_\pi, \quad \forall \pivvπ?,?π

Greedy Optimal Policy

  • For any s∈Ss \in \mathcal{S}sS, the deterministic greedy policy

    π(a∣s)={1,a=a(s)0,a≠a(s)\pi^(a \mid s) = \begin{cases} 1, & a = a^(s) \\ 0, & a \neq a^(s) \end{cases}π(as)={1,0,?a=a(s)a=a(s)?

  • is an optimal policy solving the BOE. Here,

    ?a(s)=arg?max?aq(s,a),?*a^(s) = \arg\max_a q^(s,a),*?a(s)=argmaxa?q(s,a),?

  • where q(s,a):=∑rp(r∣s,a)r+γ∑s′p(s′∣s,a)v?(s′)q^(s,a) := \sum_r p(r \mid s,a) r + \gamma \sum_{s'} p(s' \mid s,a) v^*(s')q(s,a):=r?p(rs,a)r+γs?p(ss,a)v?(s)

  • Proof

    π(s)=arg?max?π∑aπ(a∣s)(∑rp(r∣s,a)r+γ∑s′p(s′∣s,a)v(s′))\pi^(s) = \arg\max_\pi \sum_a \pi(a \mid s) \left( \sum_r p(r \mid s,a) r + \gamma \sum_{s'} p(s' \mid s,a) v^(s') \right)π(s)=argmaxπ?a?π(as)(r?p(rs,a)r+γs?p(ss,a)v(s))

對公式的概括

  1. v?v^*v? 的意義

    • v?v^*v? 是一個“理想值表”,它告訴你:從每個狀態出發,如果以后一直做出最優選擇,能拿到的總回報是多少

    • 它滿足一個自洽的關系式(Bellman 最優性方程):

      v?(s)=max?a[即時獎勵+γ×未來價值]v^*(s) = \max_a \Big[\text{即時獎勵} + \gamma \times \text{未來價值}\Big]v?(s)=maxa?[即時獎勵+γ×未來價值]

  2. π?\pi^*π? 的意義

    • π?\pi^*π? 是“最優策略”,它規定了:在每個狀態下應該采取哪個動作,才能保證總回報不比任何其他策略差
    • 從公式上看,π?\pi^*π? 就是選擇能讓 v?v^*v? 達到最大的那個動作(也就是“貪心選擇”)。
  3. Policy Optimality 定理

    • 對于任意其他策略 π\piπ,它的價值函數 vπv_\pivπ? 都不會超過 v?v^*v?
    • v?v^*v? 是所有策略里能實現的最高水平,它一定支配所有其他策略的價值表。
  4. Greedy Optimal Policy 定理

    • 只要你已經有了 v?v^*v?,那么直接在每個狀態里“選那個讓回報最大化的動作”就能得到 π?\pi^*π?
    • 最優策略其實就是“貪心地”選動作,但前提是這個貪心是基于正確的 v?v^*v?

更進一步的解釋

  1. 為什么要先有 v?v^*v? 才能得到 π?\pi^*π?
    • 因為 π?\pi^*π? 的定義依賴于“未來回報”,而未來回報就是由 v?v^*v? 描述的。
    • 一旦知道了 v?v^*v?,最優策略就能“順理成章”地通過貪心法則推出來。
  2. 為什么 v?v^*v? 比任何 vπv_\pivπ? 都大?
    • vπv_\pivπ? 是“固定策略下”的表現。
    • v?v^*v? 是在每一步都挑選最優動作的表現。
    • 顯然,如果你隨時都能選最好的動作,你的表現不可能比其他任何固定策略差
  3. 為什么貪心策略一定最優?
    • 因為 Bellman 方程已經保證了:在 v?v^*v? 下,每個狀態的最優價值都等于“選擇最優動作”得到的回報。
    • 所以只要你在每個狀態都執行這個“最優動作”,整個過程的價值函數自然等于 v?v^*v?
    • 也就是說:貪心 + 正確的價值表 = 全局最優策略

Analyzing optimal policies

What factors determine the optimal policy?

  • It can be clearly seen from the BOE

    v(s)=max?π∑aπ(a∣s)(∑rp(r∣s,a)r+γ∑s′p(s′∣s,a)v(s′))v(s) = \max_\pi \sum_a \pi(a \mid s) \left( \sum_r p(r \mid s,a) r \;+\; \gamma \sum_{s'} p(s' \mid s,a) v(s') \right)v(s)=maxπ?a?π(as)(r?p(rs,a)r+γs?p(ss,a)v(s))

  • that there are three factors:

    • Reward design: rrr
    • System model: p(s′∣s,a),p(r∣s,a)p(s' \mid s,a), \; p(r \mid s,a)p(ss,a),p(rs,a)
    • Discount rate: γ\gammaγ
  • In this equation, v(s),v(s′),π(a∣s)v(s), v(s'), \pi(a \mid s)v(s),v(s),π(as) are unknowns to be calculated.

Optimal Policy Invariance

  • Consider a Markov decision process with v?∈R∣S∣v^* \in \mathbb{R}^{|\mathcal{S}|}v?RS as the optimal state value satisfying

    v?=max?π(rπ+γPπv?).v^* = \max_\pi (r_\pi + \gamma P_\pi v^*).v?=maxπ?(rπ?+γPπ?v?).

  • If every reward rrr is changed by an affine transformation to ar+bar + bar+b, where a,b∈Ra, b \in \mathbb{R}a,bR and a≠0a \neq 0a=0, then the corresponding optimal state value v′v'v is also an affine transformation of v?v^*v?:

    v′=av?+b1?γ1,v' = a v^* + \frac{b}{1-\gamma} \mathbf{1},v=av?+1?γb?1,

    • where γ∈(0,1)\gamma \in (0,1)γ(0,1) is the discount rate and 1=[1,…,1]T\mathbf{1} = [1, \ldots, 1]^T1=[1,,1]T.
  • Consequently, the optimal policies are invariant to the affine transformation of the reward signals.


總結

Bellman 最優性方程刻畫了在所有策略中選擇最優策略的價值函數,它保證存在唯一的最優狀態價值 v?v^*v?,并且通過對每個狀態下的動作取最大化(貪心原則)即可導出最優策略 π?\pi^*π?,同時最優策略的性質只依賴于獎勵設計、環境轉移模型和折扣因子,而對獎勵的仿射變換保持不變。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/95767.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/95767.shtml
英文地址,請注明出處:http://en.pswp.cn/web/95767.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

有序數組,距離目標最近的k個數 二分查找

🤔 新手做題思路:第1步:理解題目- 找距離x最近的k個數- 數組已排序- 返回結果也要排序(升序)- 距離相同時,選擇較小的數第2步:關鍵insight- 數組已排序 → 考慮二分查找- 最近的k個數一定是連續…

學習心得分享

我認為知識是一定要系統化的學習,結構化梳理,這樣在運用或思考的時候,能夠回憶起自己在這一塊梳理的知識結構,如果有記錄那么能快速回憶并理解,如果沒有記錄,那么說明對自己來說超綱了,把知識進…

為什么說 Linode 和 DigitalOcean 的差距,不止于 VPS?

在今天這個全球化的商業戰場上,中國企業的出海已從“選擇題”變為“必答題”。當我們滿懷雄心,將產品和業務推向海外市場時,基礎設施的選擇,往往是決定成敗的第一步。它不僅關乎成本與性能,更直接影響著團隊的開發效率…

NSSCTF每日一題_Web_[SWPUCTF 2022 新生賽]奇妙的MD5

為了保持做題的感覺和持續學習,也就有了每日一題系列,選一些有意義的題目或者一些CTF新穎題目作為參考學習。[SWPUCTF 2022 新生賽]奇妙的MD51. 訪問首頁界面并進行分析估計題目MD5提示,查詢得知ffifdyop 這個字符串是一個奇妙的MD5字符串因為將“ffifdy…

服務器IP暴露被攻擊了怎么辦?

當服務器IP暴露后,可能會面臨各種網絡攻擊,如DDoS攻擊、端口掃描、惡意入侵等,這將嚴重影響服務器的正常運行和數據安全。本文將從檢測攻擊類型、采取緊急防護措施、優化服務器配置、尋求專業支持以及預防未來攻擊五個方面,詳細探…

TDengine 時間函數 TIMETRUNCATE 用戶手冊

TDengine TIMETRUNCATE 函數用戶使用手冊 函數概述 TIMETRUNCATE 是 TDengine 中的一個時間處理標量函數,用于將時間戳按照指定的時間單位進行截斷操作。該函數在時間數據聚合、分組和統計分析中非常有用,特別適用于智能電表等時序數據的分析場景。 語…

Linux電腦怎樣投屏到客廳的大電視?支持遠程投屏嗎?

一般的電腦投屏軟件都會推出Windows版本和macOS版本,雖然這兩個版本已經覆蓋大部分消費者的常用電腦,但是依然有一部分群體因為電腦系統版本問題不能使用投屏軟件。 如果你當前使用的是Linux系統的電腦,而且又要將電腦投屏投屏到客廳的大電視…

MP4視頻太大如何壓縮?分享6種簡單便捷的壓縮小技巧

隨著拍攝高清視頻的設備越來越多,我們經常會遇到MP4視頻文件體積過大的問題,無論是上傳到社交平臺、發送給朋友,還是存儲在設備中,過大的視頻文件都會帶來諸多不便。那么,MP4視頻太大怎么壓縮呢?本文將介紹…

k8s 部署 redis

創建部署文件 vim redis.yaml添加如下內容: apiVersion: v1 kind: Namespace metadata:name: redis --- apiVersion: v1 kind: Secret metadata:name: redis-passwordnamespace: redis type: Opaque data:password: d2d3cmhnZWE # 建議生產環境使用更復雜的密碼 ---…

FFMPEG H264

一、H264壓縮編碼1.1 H264 中的 I 幀、P幀和 B幀H264 使用幀內壓縮和幀間壓縮的方式提高編碼壓縮率;H264 采用了獨特的 I 幀、P 幀和 B 幀策略來實現,連續幀之間的壓縮;1.2 其他概念GOP(圖像組):一個IDR幀到…

Unity 解決天空盒中間出現一條線

問題解決找到天空盒對應貼圖,在Inspector 面板中找到Advanced →Generate Mip Maps 并取消勾選即可。效果動態修改天空盒RenderSettings.skybox targetSkyboxMaterial; DynamicGI.UpdateEnvironment();

Python爬蟲實戰:研究Showcase模塊,構建電商平臺銷售數據采集和分析系統

1. 引言 1.1 研究背景 在數字經濟快速發展的今天,電商平臺積累了海量的商品信息、交易數據和用戶反饋,這些數據蘊含著豐富的市場洞察。根據中國電子商務研究中心數據,2024 年我國網絡零售市場規模突破 15 萬億元,平臺商品數據呈現指數級增長。如何高效提取這些數據并轉化…

C++中的Reactor和Proactor模型進行系統性解析

<摘要> 本解析系統闡述了網絡編程中Reactor與Proactor兩種高性能I/O模型的核心概念。Reactor基于同步I/O多路復用&#xff0c;通過事件循環分發通知&#xff0c;由應用層自行完成I/O操作&#xff1b;而Proactor則基于異步I/O&#xff0c;由操作系統完成I/O操作后主動回調…

【技術教程】如何將文檔編輯器集成至基于Node.js的網頁應用程序中

當今數字化時代&#xff0c;Web應用對在線文檔編輯的需求日益增長。無論是構建在線辦公系統、內容管理平臺還是協作工具&#xff0c;讓用戶能夠直接在瀏覽器中編輯和處理文檔已成為基本需求。 想知道如何為你的 Node.js 應用添加強大的在線文檔編輯功能嗎&#xff1f;本文手把…

[論文閱讀] 人工智能 + 軟件工程 | 別讓AI寫的代碼帶“漏洞”!無觸發投毒攻擊的防御困境與啟示

別讓AI寫的代碼帶“漏洞”&#xff01;無觸發投毒攻擊的防御困境與啟示 論文信息 原標題&#xff1a;Evaluating Defenses Against Trigger-Free Data Poisoning Attacks on NL-to-Code Models&#xff08;評估NL-to-Code模型應對無觸發數據投毒攻擊的防御方法&#xff09;主要…

【Windows】通過 runas 命令實現多用戶權限測試的完整流程

? 目錄 ?&#x1f6eb; 導讀需求1?? 前期準備&#xff1a;創建管理員/普通測試用戶1.1 創建普通用戶Test&#xff08;無管理員權限&#xff09;1.2 創建管理員用戶Admin&#xff08;含管理員權限&#xff09;2?? 核心操作&#xff1a;通過runas命令切換用戶命令行環境2.1…

新后端漏洞(上)- H2 Database Console 未授權訪問

漏洞介紹&#xff1a; H2 database是一款Java內存數據庫&#xff0c;多用于單元測試。 H2 database自帶一個Web管理頁面&#xff0c;在Spirng開發中&#xff0c;如果我們設置如下選項&#xff0c;即可允許外部用戶訪問Web管理頁面&#xff0c;且沒有鑒權&#xff1a; spring.h2…

2025-09-04 HTML3——區塊布局與表單

文章目錄1 塊元素與行內元素1.1 塊元素 (Block-level Element)1.2 行內元素 (Inline Element)2 HTML 布局2.1 使用 <div> 元素2.2 使用 <table> 元素3 表單 (<form>)3.1 輸入域&#xff08;<input>&#xff09;3.1.1 文本域&#xff08;Text Fields&am…

云數據庫服務(參考自騰訊云計算工程師認證課程)更新中......

數據庫基礎介紹面臨的挑戰&#xff1a;數據庫系統架構&#xff1a; 數據庫DB、數據庫管理系統DBMS&#xff08;負責數據庫的搭建、使用和維護的系統軟件&#xff0c;通過組織、索引、查詢、修改數據庫文件、實現數據定義、組織、存儲、管理以及數據庫操作、運行和維護等主要功能…

源滾滾AI編程SillyTavern酒館配置Claude Code API教程

什么是酒館 SillyTavern&#xff08;簡稱 ST&#xff09;是一款本地安裝的用戶界面&#xff0c;讓你能夠與文本生成大模型&#xff08;LLM&#xff09;、圖像生成引擎以及語音合成&#xff08;TTS&#xff09;模型進行交互。我們的目標是盡可能賦予用戶對 LLM 提示詞的最大掌控…