【强化学习】09——价值和策略近似逼近方法

news/2024/5/19 0:11:16 标签: 强化学习, 算法, 人工智能, 机器学习

文章目录

  • 前言
  • 对状态/动作进行离散化
  • 参数化值函数近似
    • 值函数近似的主要形式
    • Incremental Methods
      • Gradient Descent
      • Linear Value Function Approximation
        • Feature Vectors特征化状态
        • Table Lookup Features
      • Incremental Prediction Algorithms
        • Monte-Carlo with Value Function Approximation
        • TD Learning with Value Function Approximation
        • TD(λ) with Value Function Approximation
      • Incremental Control Algorithms
        • Control with Value Function Approximation
        • Action-Value Function Approximation
        • Linear Action-Value Function Approximation
        • Incremental Control Algorithms
    • Example1 Mountain Car
    • Example2 DQN

前言

之前所有模型的做法都是基于创建一个查询表,在表中维护状态值函数 V ( s ) V(s) V(s)或状态-动作值函数 Q ( s , a ) Q(s,a) Q(s,a)。但对于大规模的MDP时,为每一个状态维护 V ( s ) V(s) V(s)或为每个状态-动作对维护 Q ( s , a ) Q(s,a) Q(s,a) 则需要面临以下问题:

  • 存储状态或动作需要大量的存储空间
  • 对于每一个状态去学习相应的价值需要耗费大量时间

大规模问题

  • 状态或者状态-动作空间非常大
  • 连续的状态或动作空间
  • 围棋博弈( 1 0 170 10^{170} 10170的状态空间)
  • 直升机,自动驾驶汽车(连续的状态空间)

因此,传统的方法不再适用。针对arge MDPs问题的主要解决方案有:

  • 对状态/动作进行离散化或分桶
  • 构建参数化的值函数估计

对状态/动作进行离散化

对于连续状态马尔可夫决策过程,我们可以对状态空间进行离散化。例如,如果用2维连续值 𝑠1, 𝑠2 表示状态,可以使用网格对状态空间进行切分从而转化为离散的状态值。在这里插入图片描述
记离散的状态值为 s ˉ \bar{s} sˉ,离散化的马尔可夫决策过程可以表示为: ( S ˉ , A , { P S ˉ a } , γ , R ) (\bar{S},A,\{P_{\bar{S}a}\},\gamma,R) (Sˉ,A,{PSˉa},γ,R),这样一来,就能够使用前述方法求解马尔可夫决策过程。

对于一个大型的离散状态马尔可夫决策过程,我们可以对状态值进一步分桶以进行采样聚合,使用先验知识将相似的离散状态归类到一起。在这里插入图片描述

离散化的方式优点
• 操作简洁直观
• 高效
• 在处理许多问题时能够达到较好效果
缺点
• 过于简单地表示价值函数𝑉,可能部分灵敏区域会被忽略
• 可能为每个离散区间假设一个常数值
• 维度灾难

参数化值函数近似

构建参数化(可学习的)函数来近似值函数
V ^ ( s , w ) ≈ V π ( s ) Q ^ ( s , a , w ) ≈ Q π ( s , a ) \begin{aligned}\hat{V}(s,\mathbf{w})&\approx V_\pi(s)\\\hat{Q}(s,a,\mathbf{w})&\approx Q_\pi(s,a)\end{aligned} V^(s,w)Q^(s,a,w)Vπ(s)Qπ(s,a) w \mathbf{w} w是近似函数的参数,可以通过强化学习进行更新
• 参数化的方法将现有可见的状态泛化到没有见过的状态上

值函数近似的主要形式

在这里插入图片描述

  • 一些函数近似
    • (一般的)线性模型
    • 神经网络
    • 决策树
    • 最近邻
    • 傅立叶/小波基底
  • 可微函数
    • (一般的)线性模型
    • 神经网络

我们希望模型适合在非稳态的(non-stationary),非独立同分布(non-iid)的数据上训练,因此参数化模型比树模型更适合。

Incremental Methods

Gradient Descent

在这里插入图片描述
梯度下降被广泛用于优化模型的参数。设 J ( w ) J(\mathbf{w}) J(w)是对参数 w \mathbf{w} w可微的函数。则 J ( w ) J(\mathbf{w}) J(w)的梯度可被定义为: ∇ w J ( w ) = ( ∂ J ( w ) ∂ w 1 ⋮ ∂ J ( w ) ∂ w n ) \nabla_{\mathbf{w}}J(\mathbf{w})=\begin{pmatrix}\frac{\partial J(\mathbf{w})}{\partial\mathbf{w}_1}\\\vdots\\\frac{\partial J(\mathbf{w})}{\partial\mathbf{w}_n}\end{pmatrix} wJ(w)= w1J(w)wnJ(w) 为了达到损失函数 J ( w ) J(\mathbf{w}) J(w)的局部最小值,调整权重向量 w \mathbf{w} w的方向以使其朝着负梯度方向进行更新。
Δ w = − 1 2 α ∇ w J ( w ) \Delta\mathbf{w}=-\frac12\alpha\nabla_\mathbf{w}J(\mathbf{w}) Δw=21αwJ(w)
其中, α \alpha α是学习率(一个正的标量值),控制每次更新的步长.

基于随机梯度下降(SGD)的值函数近似
目标:找到参数向量 w \mathbf{w} w最小化值函数近似值与真实值之间的均方误差 J ( w ) = E π [ ( V π ( s ) − V ^ ( s , w ) ) 2 ] J(\mathbf{w})=\mathbb{E}_\pi\left[(V_\pi(s)-\hat{V}(s,\mathbf{w}))^2\right] J(w)=Eπ[(Vπ(s)V^(s,w))2]误差减小的梯度方向 Δ w = − 1 2 α ∇ w J ( w ) = α E π [ ( V π ( s ) − V ^ ( s , w ) ) ∇ w V ^ ( s , w ) ] \begin{aligned} \Delta \mathbf{w}& =-\frac12\alpha\nabla_{\mathbf{w}}J(\mathbf{w}) \\ &=\alpha\mathbb{E}_\pi\left[(V_\pi(s)-\hat{V}(s,\mathbf{w}))\nabla_\mathbf{w}\hat{V}(s,\mathbf{w})\right] \end{aligned} Δw=21αwJ(w)=αEπ[(Vπ(s)V^(s,w))wV^(s,w)]单次采样进行随机梯度下降 Δ w = α ( V π ( s ) − V ^ ( s , w ) ) ∇ w V ^ ( s , w ) \Delta\mathbf{w}=\alpha(V_\pi(s)-\hat{V}(s,\mathbf{w}))\nabla_\mathbf{w}\hat{V}(s,\mathbf{w}) Δw=α(Vπ(s)V^(s,w))wV^(s,w)

Linear Value Function Approximation

Feature Vectors特征化状态

用一个特征向量表示状态
x ( s ) = [ x 1 ( s ) ⋮ x k ( s ) ] x(s)=\begin{bmatrix}x_1(s)\\\varvdots\\x_k(s)\end{bmatrix} x(s)= x1(s)xk(s)
以直升机控制问题为例
• 3D位置
• 3D速度(位置的变化量)
• 3D加速度(速度的变化量)
用特征的线性组合表示价值函数 V ^ ( s , w ) = x ( s ) ⊤ w = ∑ j = 1 n x j ( s ) w j \hat{V}(s,\mathbf{w})=\mathbf{x}(s)^\top\mathbf{w}=\sum_{j=1}^n\mathbf{x}_j(s)\mathbf{w}_j V^(s,w)=x(s)w=j=1nxj(s)wj
目标函数是参数 w \mathbf{w} w的二次函数 J ( w ) = E π [ ( V π ( s ) − x ( s ) ⊤ w ) 2 ] J(\mathbf{w})=\mathbb{E}_\pi\left[(V_\pi(s)-\mathbf{x}(s)^\top\mathbf{w})^2\right] J(w)=Eπ[(Vπ(s)x(s)w)2]

因而随机梯度下降能够收敛到全局最优解上 ∇ w V ^ ( s , w ) = x ( s ) Δ w = α ( V π ( s ) − V ^ ( s , w ) ) x ( s ) \begin{aligned} \nabla_\mathbf{w}\hat{V}(s,\mathbf{w})& =\mathbf{x}(\mathcal{s}) \\ \Delta \mathbf{w}& =\alpha(V_\pi(s)-\hat{V}(s,\mathbf{w}))\mathbf{x}(s) \end{aligned} wV^(s,w)Δw=x(s)=α(Vπ(s)V^(s,w))x(s)Update = step-size × prediction error × feature value

Table Lookup Features

之前基于表去查找的方法其实是线性状态值函数近似的一种特殊形式。
Table Lookup的Features(只有 s = s i s=s_i s=si时才会是1,其他都是0):
x t a b l e ( s ) = ( 1 ( s = s 1 ) ⋮ 1 ( s = s n ) ) \mathbf{x}^{table}(s)=\begin{pmatrix}\mathbf{1}(s=s_1)\\\varvdots\\\mathbf{1}(s=s_n)\end{pmatrix} xtable(s)= 1(s=s1)1(s=sn)
值函数则是向量于权重的乘积 V ^ ( s , w ) = ( 1 ( s = s 1 ) ⋮ 1 ( s = s n ) ) ⋅ ( w 1 ⋮ w n ) \hat{V}(s,\mathbf{w})=\begin{pmatrix}\mathbf{1}(s=s_1)\\\varvdots\\\mathbf{1}(s=s_n)\end{pmatrix}\cdot\begin{pmatrix}\mathbf{w}_1\\\varvdots\\\mathbf{w}_n\end{pmatrix} V^(s,w)= 1(s=s1)1(s=sn) w1wn

Incremental Prediction Algorithms

在之前的描述中,我们假定 V π ( s ) V_\pi(s) Vπ(s)类似于监督学习中的label,是被给定的。但在RL是无监督学习,只有奖励。因此可以做如下替换:

  • 对于 MC,用 G t \textcolor{red}{G_t} Gt替换 V π ( s ) V_\pi(s) Vπ(s) Δ w = α ( G t − V ^ ( s t , w ) ) ∇ w V ^ ( s t , w ) \Delta\mathbf{w}=\alpha(\textcolor{red}{G_t}-\hat{V}(s_t,\mathbf{w}))\nabla_\mathbf{w}\hat{V}(s_t,\mathbf{w}) Δw=α(GtV^(st,w))wV^(st,w)
  • 对于TD(0),用 R t + 1 + γ V ^ ( s t + 1 , w ) \textcolor{red}{R_{t+1}+\gamma\hat{V}(s_{t+1},\mathbf{w})} Rt+1+γV^(st+1,w)替换 V π ( s ) V_\pi(s) Vπ(s): Δ w = α ( R t + 1 + γ V ^ ( s t + 1 , w ) − V ^ ( s t , w ) ) ∇ w V ^ ( s t , w ) \Delta\mathbf{w}=\alpha(\textcolor{red}{R_{t+1}+\gamma\hat{V}(s_{t+1},\mathbf{w})}-\hat{V}(s_t,\mathbf{w}))\nabla_\mathbf{w}\hat{V}(s_t,\mathbf{w}) Δw=α(Rt+1+γV^(st+1,w)V^(st,w))wV^(st,w)
  • 对于TD(λ),用 G t λ \textcolor{red}{G_t^λ} Gtλ替换 V π ( s ) V_\pi(s) Vπ(s): Δ w = α ( G t λ − V ^ ( s t , w ) ) ∇ w V ^ ( s t , w ) \Delta\mathbf{w}=\alpha(\textcolor{red}{G_t^λ}-\hat{V}(s_t,\mathbf{w}))\nabla_\mathbf{w}\hat{V}(s_t,\mathbf{w}) Δw=α(GtλV^(st,w))wV^(st,w)
Monte-Carlo with Value Function Approximation
  • G t G_t Gt是对 V π ( s t ) V_\pi(s_t) Vπ(st)无偏但有噪声的采样
  • 可以在“训练数据”上运用监督学习对价值函数进行预测 ⟨ s 1 , G 1 ⟩ , ⟨ s 2 , G 2 ⟩ , . . . , ⟨ s T , G T ⟩ \langle s_1,G_1\rangle,\langle s_2,G_2\rangle,...,\langle s_T,G_T\rangle s1,G1,s2,G2,...,sT,GT
  • 对于每个数据样本 ⟨ s t , G t ⟩ \langle s_t,G_t\rangle st,Gt(linear Monte-Carlo policy evaluation) Δ w = α ( G t − V ^ ( S t , w ) ) ∇ w V ^ ( s t , w ) = α ( G t − V ^ ( s t , w ) ) x ( s t ) \begin{gathered} \Delta \mathbf{w} =\alpha(\textcolor{red}{G_t}-\hat{V}(S_t,\mathbf{w}))\nabla_\mathbf{w}\hat{V}(s_t,\mathbf{w}) \\ =\alpha(G_t-\hat{V}(s_t,\mathbf{w}))\mathbf{x}(s_t) \end{gathered} Δw=α(GtV^(St,w))wV^(st,w)=α(GtV^(st,w))x(st)

蒙特卡洛预测至少能收敛到一个局部最优解
• 在价值函数为线性的情况下可以收敛到全局最优

TD Learning with Value Function Approximation
  • R t + 1 + γ V ^ ( s t + 1 , w ) {R_{t+1}+\gamma\hat{V}(s_{t+1},\mathbf{w})} Rt+1+γV^(st+1,w)是对 V π ( s t ) V_\pi(s_t) Vπ(st)的有偏采样
  • 同样可以在“训练数据”上运用监督学习对价值函数进行预测 ⟨ S 1 , R 2 + γ v ^ ( S 2 , w ) ⟩ , ⟨ S 2 , R 3 + γ v ^ ( S 3 , w ) ⟩ , . . . , ⟨ S T − 1 , R T ⟩ \langle S_1,R_2+\gamma\hat{v}(S_2,\mathbf{w})\rangle,\langle S_2,R_3+\gamma\hat{v}(S_3,\mathbf{w})\rangle,...,\langle S_{T-1},R_T\rangle S1,R2+γv^(S2,w)⟩,S2,R3+γv^(S3,w)⟩,...,ST1,RT
  • linear TD(0) Δ w = α ( R + γ V ^ ( s ′ , w ) − V ^ ( s , w ) ) ∇ w V ^ ( s , w ) = α δ x ( s ) \begin{aligned} \Delta \mathbf{w}& =\alpha(\textcolor{red}{R+\gamma\hat{V}(s^{\prime},\mathbf{w})}-\hat{V}(s,\mathbf{w}))\nabla_{\mathbf{w}}\hat{V}(s,\mathbf{w}) \\ &=\alpha\delta\mathbf{x}(s) \end{aligned} Δw=α(R+γV^(s,w)V^(s,w))wV^(s,w)=αδx(s)
  • 线性情况下时序差分学习(接近)收敛到全局最优解
TD(λ) with Value Function Approximation
  • G t λ {G_t^λ} Gtλ是对 V π ( s t ) V_\pi(s_t) Vπ(st)的有偏采样
  • 可以在“训练数据”上运用监督学习对价值函数进行预测 ⟨ S 1 , G 1 λ ⟩ , ⟨ S 2 , G 2 λ ⟩ , . . . , ⟨ S T − 1 , G T − 1 λ ⟩ \left\langle S_1,G_1^\lambda\right\rangle,\left\langle S_2,G_2^\lambda\right\rangle,...,\left\langle S_{T-1},G_{T-1}^\lambda\right\rangle S1,G1λ,S2,G2λ,...,ST1,GT1λ
  • Forward view linear TD(λ) Δ w = α ( G t λ − V ^ ( S t , w ) ) ∇ w V ^ ( s t , w ) = α ( G t λ − V ^ ( s t , w ) ) x ( s t ) \begin{gathered} \Delta \mathbf{w} =\alpha(\textcolor{red}{G_t^\lambda}-\hat{V}(S_t,\mathbf{w}))\nabla_\mathbf{w}\hat{V}(s_t,\mathbf{w}) \\ =\alpha(\textcolor{red}{G_t^\lambda}-\hat{V}(s_t,\mathbf{w}))\mathbf{x}(s_t) \end{gathered} Δw=α(GtλV^(St,w))wV^(st,w)=α(GtλV^(st,w))x(st)
  • Backward view linear TD(λ) δ t = R t + 1 + γ V ^ ( s t + 1 , w ) − V ^ ( s t , w ) E t = γ λ E t − 1 + x ( s t ) Δ w = α δ t E t \begin{aligned} \delta_{t}& =R_{t+1}+\gamma\hat{V}(s_{t+1},\mathbf{w})-\hat{V}(s_t,\mathbf{w}) \\ E_{t}& =\gamma\lambda E_{t-1}+\mathbf{x}(s_t) \\ \Delta \mathbf{w}& =\alpha\delta_tE_t \end{aligned} δtEtΔw=Rt+1+γV^(st+1,w)V^(st,w)=γλEt1+x(st)=αδtEt
  • Backward view linear TD(λ)和Forward view linear TD(λ)是等效的

Incremental Control Algorithms

Control with Value Function Approximation

在这里插入图片描述

  • 策略评估:近似策略评估 Q w ≈ Q π Q_\mathbf{w}\approx Q_\pi QwQπ
  • 策略改进:𝜖-贪心策略提升
Action-Value Function Approximation

对动作-状态值函数进行近似 Q ^ ( s , a , w ) ≈ Q π ( s , a ) \hat{Q}(s,a,\mathbf{w})\approx Q_\pi(s,a) Q^(s,a,w)Qπ(s,a)
最小均方误差 J ( w ) = E π [ ( Q π ( s , a ) − Q ^ ( s , a , w ) ) 2 ] J(\mathbf{w})=\mathbb{E}_\pi\left[(Q_\pi(s,a)-\hat{Q}(s,a,\mathbf{w}))^2\right] J(w)=Eπ[(Qπ(s,a)Q^(s,a,w))2]
在单个样本上进行随机梯度下降 − 1 2 ∇ w J ( w ) = ( Q π ( s , a ) − Q ^ ( s , a , w ) ) ∇ w Q ^ ( s , a , w ) Δ w = α ( Q π ( s , a ) − Q ^ ( s , a , w ) ) ∇ w Q ^ ( s , a , w ) \begin{aligned} -\frac12\nabla_\mathbf{w}J(\mathbf{w})& =(Q_\pi(s,a)-\hat{Q}(s,a,\mathbf{w}))\nabla_\mathbf{w}\hat{Q}(s,a,\mathbf{w}) \\ \Delta w& =\alpha(Q_\pi(s,a)-\hat{Q}(s,a,\mathbf{w}))\nabla_\mathbf{w}\hat{Q}(s,a,\mathbf{w}) \end{aligned} 21wJ(w)Δw=(Qπ(s,a)Q^(s,a,w))wQ^(s,a,w)=α(Qπ(s,a)Q^(s,a,w))wQ^(s,a,w)

Linear Action-Value Function Approximation

用特征向量表示状态-动作对 x ( s , a ) = [ x 1 ( s , a ) ⋮ x k ( s , a ) ] x(s,a)=\begin{bmatrix}x_1(s,a)\\\varvdots\\x_k(s,a)\end{bmatrix} x(s,a)= x1(s,a)xk(s,a)
线性情况下,参数化后𝑄函数 Q ^ ( s , a , w ) = x ( s , a ) ⊤ w = ∑ j = 1 n x j ( s , a ) w j \hat{Q}(s,a,\mathbf{w})=\mathbf{x}(s,a)^\top\mathbf{w}=\sum_{j=1}^n\mathbf{x}_j(s,a)\mathbf{w}_j Q^(s,a,w)=x(s,a)w=j=1nxj(s,a)wj
利用随机梯度下降更新 ∇ w Q ^ ( s , a , w ) = x ( s , a ) Δ w = α ( Q π ( s , a ) − Q ^ ( s , a , w ) ) x ( s , a ) \begin{aligned} \nabla_\mathbf{w}\hat{Q}(s,a,\mathbf{w})& =\mathbf{x}(s,a) \\ \Delta \mathbf{w}& =\alpha(Q_\pi(s,a)-\hat{Q}(s,a,\mathbf{w}))\mathbf{x}(s,a) \end{aligned} wQ^(s,a,w)Δw=x(s,a)=α(Qπ(s,a)Q^(s,a,w))x(s,a)

Incremental Control Algorithms

类似于Prediction的方法做如下替换:

  • 对于 MC,用 G t \textcolor{red}{G_t} Gt替换 Q π ( s , a ) Q_\pi(s,a) Qπ(s,a) Δ w = α ( G t − Q ^ ( s t , a t , w ) ) ∇ w Q ^ ( s t , a t , w ) \Delta\mathbf{w}=\alpha(\textcolor{red}{G_t}-\hat{Q}(s_t,a_t,\mathbf{w}))\nabla_\mathbf{w}\hat{Q}(s_t,a_t,\mathbf{w}) Δw=α(GtQ^(st,at,w))wQ^(st,at,w)
  • 对于TD(0),用 R t + 1 + γ Q ^ ( s t + 1 , a t + 1 , w ) \textcolor{red}{R_{t+1}+\gamma\hat{Q}(s_{t+1},a_{t+1},\mathbf{w})} Rt+1+γQ^(st+1,at+1,w)替换 Q π ( s , a ) Q_\pi(s,a) Qπ(s,a): Δ w = α ( R t + 1 + γ Q ^ ( s t + 1 , a t + 1 , w ) − Q ^ ( s t , a t , w ) ) ∇ w Q ^ ( s t , a t , w ) \Delta\mathbf{w}=\alpha(\textcolor{red}{R_{t+1}+\gamma\hat{Q}(s_{t+1},a_{t+1},\mathbf{w})}-\hat{Q}(s_t,a_t,\mathbf{w}))\nabla_\mathbf{w}\hat{Q}(s_t,a_t,\mathbf{w}) Δw=α(Rt+1+γQ^(st+1,at+1,w)Q^(st,at,w))wQ^(st,at,w)
  • 对于TD(λ),用 G t λ \textcolor{red}{G_t^λ} Gtλ替换 Q π ( s , a ) Q_\pi(s,a) Qπ(s,a): Δ w = α ( G t λ − Q ^ ( s t , a t , w ) ) ∇ w Q ^ ( s t , a t , w ) \Delta\mathbf{w}=\alpha(\textcolor{red}{G_t^λ}-\hat{Q}(s_t,a_t,\mathbf{w}))\nabla_\mathbf{w}\hat{Q}(s_t,a_t,\mathbf{w}) Δw=α(GtλQ^(st,at,w))wQ^(st,at,w)

虽然 w \mathbf{w} w在时序差分学习的目标中出现,但是我们并不需要计算目标函数的梯度。因为目标值不是可学习的,就是单纯固定的一个值。如果同时学习,会造成训练不稳定。

Example1 Mountain Car

在这里插入图片描述

Example2 DQN

使用深度神经网络表示Q函数。输入s,输出n+1个a(多一个no input),选出最大的a作为实际输出。
在这里插入图片描述
DQN 使用经验回放(experience replay)和 固定的目标Q值

L i ( θ i ) = E ( s , a , r , s ′ ) ∼ U ( D ) [ ( r + γ max ⁡ a ′ Q ( s ′ , a ′ ; θ i − ) ⏟ 目标Q值 − Q ( s , a ; θ i ) ⏟ 预测Q值 ) 2 ] \begin{aligned}L_i(\theta_i)=\mathbb{E}_{(s,a,r,s')\sim U(D)}&\left[\left(\underbrace{r+\gamma\max_{a′}Q(s',a';\theta_i^-)}_\text{目标Q值}-\underbrace{Q(s,a;\theta_i)}_\text{预测Q值}\right)^2\right]\end{aligned} Li(θi)=E(s,a,r,s)U(D) 目标Q r+γamaxQ(s,a;θi)预测Q Q(s,a;θi) 2

• 𝜃𝑖是第𝑖轮迭代中将要更新的网络参数
• 通过标准的反向传播算法进行更新
• 𝜃𝑖−是目标网络参数
• 仅在𝜃𝑖每更新𝐶步后进行更新
• (𝑠, 𝑎, 𝑟, 𝑠′) ~𝑈 (𝐷) :样本从经验池𝐷中均匀抽样
• 这样做可以避免在近期经验上过拟合
[1] 伯禹AI
[2] https://www.deepmind.com/learning-resources/introduction-to-reinforcement-learning-with-david-silver
[3] 动手学强化学习
[4] Reinforcement Learning


http://www.niftyadmin.cn/n/5124276.html

相关文章

jenkins、ant、selenium、testng搭建自动化测试框架

如果在你的理解中自动化测试就是在eclipse里面讲webdriver的包引入,然后写一些测试脚本,这就是你所说的自动化测试,其实这个还不能算是真正的自动化测试,你见过每次需要运行的时候还需要打开eclipse然后去选择运行文件吗&#xff…

如何利用视频号提取视频,视频号下载视频教程

随着视频号的兴起,越来越多的人开始关注这个平台,并希望能够提取视频号中的精彩视频。然而,视频号并不支持直接下载视频,也不能复制链接。那么,我们如何才能实现视频号提取视频的需求呢?答案就是借助视频下…

vim 常用的命令

普通模式: 1、u 撤回2、 yy 复制光标当前行 3、 p 粘贴 (可以及其粘贴的次数 例如: 3p)4、 dd 删除当前行 (3dd 删除当前行向下3行)5 、 b 上一个词,w 下一个词6 、 shift$ 行尾 shift…

怎么防止U盘复制电脑文件

怎么防止U盘复制电脑文件 安企神U盘管理系统下载使用 说到防止U盘复制电脑文件也是一个老生常谈的话题了,因为U盘的主要目的是在不同设备之间传输文件。对于企业来说,有的重要信息是不能对外泄露的,出于安全考虑,企业往往是禁止…

OpenCV 根据极线确定点匹配

import numpy as np import cv2 from backend.__detector import detect_markers_solo from backend._gs_ import aruco_dict, stereo_camera# 通过基础矩阵 验证左右两幅图像中的点是否是匹配点 def check_match_by_fundentalmat(uvs1, uvs2, F):for i in range(len(uvs1)):u…

PHP 同城服务共享茶室软硬件结合小程序开发的注意事项?

在现在共享经济的兴起时代,同城服务共享茶室作为一种新型的商业模式,越来越受到人们的关注。为了提高用户体验和服务质量,开发一款基于PHP的同城服务共享茶室软硬件结合的小程序成为了必要的选择。本文将详细介绍在开发过程中需要注意的事项。…

java-后端调用第三方接口返回图片流给前端

一、背景 有个需求是这样的,客户端直接通过外网访问oss获取图片需要额外付费,考虑到成本问题,修改技术方案为:客户端将请求链接发给后端,后端根据请求做一定的截取或拼接,通过内网调用oss,再将…

20231026_java基础_设计模式

20231026_java基础 设计模式概念分类 单例模式概念代码实现饿汉式懒汉式对比差异 总结 设计模式 概念 分类 归纳 运用 单例模式 概念 代码实现 饿汉式 测试:获取实例对象,并测试有多个该对象时,他们是否相同 懒汉式 对比差异 代码实现中 饿 懒 过程中 并发时 总结 111