強化學習之基于無模型的算法之時序差分法

2、時序差分法(TD)

核心思想

TD 方法通過 引導值估計來學習最優策略。它利用當前的估計值和下一個時間步的信息來更新價值函數, 這種方法被稱為“引導”(bootstrapping)。而不需要像蒙特卡羅方法那樣等待一個完整的 episode 結束才進行更新,也不需要像動態規劃方法那樣已知環境的轉移概率。
狀態價值函數更新
以最基本的 TD(0) 為例,狀態價值函數 V( s) 的更新公式為:
其中:
  • st?:當前狀態;
  • rt+1?:從狀態?stst??轉移到下一狀態?st+1st+1??所獲得的獎勵;
  • γ:折扣因子,用于衡量未來獎勵的重要性;
  • α:學習率,控制更新的步長。
動作價值函數更新
對于動作價值函數 Q(s,a) Q( s, a),常見的 TD 更新方式如 Q-learning
其中:
  • maxa′?Q(st+1?,a′):在狀態st+1??下所有可能動作的最大 Q 值。

算法特點

在線學習
TD 方法可以在與環境交互的過程中實時學習,每經歷一個時間步即可進行一次價值函數更新,無需等到整個 episode 結束,適合實時性要求高的場景。

樣本效率高

相比蒙特卡羅方法,TD 方法利用了環境的時序信息,通過“引導”機制減少對大量樣本的依賴,在樣本有限的情況下也能取得較好的學習效果。

融合兩者優點

  • 不需要環境模型(類似蒙特卡羅);
  • 利用貝爾曼方程進行更新(類似動態規劃);
  • 克服了蒙特卡羅方法中對完整 episode 的依賴,提高學習效率。
局限性
  • 收斂性問題:在復雜環境中可能出現收斂慢或不收斂的問題,尤其在狀態空間大或獎勵稀疏時表現不佳。
  • 對超參數敏感:算法性能受學習率?α、折扣因子?γ?等影響較大,需多次實驗調參。
  • 模型泛化能力有限:通常只能針對特定環境學習最優策略,環境變化后需重新訓練。

1)TD learning of state values

核心思想

TD(0) 是最基礎的狀態值學習方法。它通過比較當前狀態的價值估計與基于后續狀態的價值估計來更新當前狀態的價值估計。
算法公式
  • TD Targetrt+1?+γV(st+1?)(基于下一狀態的預估價值)。
  • TD Errorδt?=rt+1?+γV(st+1?)?V(st?)(當前估計的偏差)。

2)TD learning of action values : Sarsa

核心思想

Sarsa 是一種在線策略(on - policy)的 TD 算法, 它直接使用行為策略生成的數據進行評估和改進該策略, 估計動作價值函數? Q(s, a)
算法公式
  • 策略依賴:動作?at+1??由當前策略(如ε-貪婪策略)生成。

偽代碼

對于每一個 episode,執行以下操作:
如果當前狀態 s t? 不是目標狀態,執行以下步驟:
經驗收集(Collect the experience)
獲取經驗元組( s t?, a t?, r t+1?, s t+1?, a t+1?):
具體來說,按照當前策略 π t?( s t?) 選擇并執行動作 a t?,得到獎勵 r t+1? 和下一狀態 s t+1?;
然后按照當前策略 π t?( s t+1?) 選擇下一個動作 a t+1?。
Q 值更新(Update q-value)(根據上述公式)
策略更新(Update policy)(使用ε-貪婪策略)

實現代碼

import time
import numpy as np
import grid_envclass Solve:def __init__(self, env: grid_env.GridEnv):self.gama = 0.9   #折扣因子,表示未來獎勵的衰減程度self.env = envself.action_space_size = env.action_space_size   #動作空間大小self.state_space_size = env.size ** 2     #狀態空間大小self.reward_space_size, self.reward_list = len(self.env.reward_list), self.env.reward_list   #獎勵self.state_value = np.zeros(shape=self.state_space_size)      #狀態值self.qvalue = np.zeros(shape=(self.state_space_size, self.action_space_size))    #動作值self.mean_policy = np.ones(shape=(self.state_space_size, self.action_space_size)) / self.action_space_size   #平均策略,表示采取每個動作概率相等self.policy = self.mean_policy.copy()def sarsa(self, alpha=0.1, epsilon=0.1, num_episodes=80):while num_episodes > 0:done = Falseself.env.reset()next_state = 0num_episodes -= 1total_rewards = 0episode_length = 0while not done:state = next_stateaction = np.random.choice(np.arange(self.action_space_size),p=self.policy[state])   #按照當前策略選擇動作_, reward, done, _, _ = self.env.step(action)   #根據當前動作得到下一狀態和獎勵,在self.env.agent_locationepisode_length += 1total_rewards += rewardnext_state = self.env.pos2state(self.env.agent_location)  #下一動作next_action = np.random.choice(np.arange(self.action_space_size),p=self.policy[next_state])  #按照當前策略選擇下一動作target = reward + self.gama * self.qvalue[next_state, next_action]error =  target - self.qvalue[state, action]   #估計偏差self.qvalue[state, action] = self.qvalue[state, action] + alpha * error   #q值更新qvalue_star = self.qvalue[state].max()action_star = self.qvalue[state].tolist().index(qvalue_star)for a in range(self.action_space_size):   #策略更新if a == action_star:self.policy[state, a] = 1 - (self.action_space_size - 1) / self.action_space_size * epsilonelse:self.policy[state, a] = 1 / self.action_space_size * epsilondef show_policy(self):# 可視化策略(Policy):將智能體的策略(每次行動的方向標注為箭頭)以圖形化的方式渲染到環境中for state in range(self.state_space_size):for action in range(self.action_space_size):policy = self.policy[state, action]self.env.render_.draw_action(pos=self.env.state2pos(state),toward=policy * 0.4 * self.env.action_to_direction[action],radius=policy * 0.1)def show_state_value(self, state_value, y_offset=0.2):# 可視化狀態價值函數(State - ValueFunction):將每個狀態的價值(長期累積獎勵的預期)以文本形式渲染到環境中。for state in range(self.state_space_size):self.env.render_.write_word(pos=self.env.state2pos(state), word=str(round(state_value[state], 1)),y_offset=y_offset,size_discount=0.7)if __name__ == "__main__":env = grid_env.GridEnv(size=5, target=[2, 3],forbidden=[[2, 2], [2, 1], [1, 1], [3, 3], [1, 3], [1, 4]],render_mode='')solver = Solve(env)solver.sarsa()solver.show_policy()solver.show_state_value(solver.state_value, y_offset=0.25)solver.env.render()

效果

3)TD learning of action values: Expected Sarsa

核心思想

Expected Sarsa 也是一種用于學習動作價值函數?Q(s, a))的 TD 算法。與 Sarsa 不同的是,它在更新時考慮了下一個狀態下所有可能動作的期望價值,而不是僅僅使用一個特定的動作。

算法公式:

偽代碼

和Sarsa類似,只是在Q 值更新時使用的是期望價值。

實現代碼

import matplotlib.pyplot as plt
import numpy as np
import grid_envclass Solve:def __init__(self, env: grid_env.GridEnv):self.gama = 0.9   #折扣因子,表示未來獎勵的衰減程度self.env = envself.action_space_size = env.action_space_size   #動作空間大小self.state_space_size = env.size ** 2     #狀態空間大小self.reward_space_size, self.reward_list = len(self.env.reward_list), self.env.reward_list   #獎勵self.state_value = np.zeros(shape=self.state_space_size)      #狀態值self.qvalue = np.zeros(shape=(self.state_space_size, self.action_space_size))    #動作值self.mean_policy = np.ones(shape=(self.state_space_size, self.action_space_size)) / self.action_space_size   #平均策略,表示采取每個動作概率相等self.policy = self.mean_policy.copy()def expected_sarsa(self, alpha=0.1, epsilon=1, num_episodes=1000):init_num = num_episodesqvalue_list = [self.qvalue, self.qvalue + 1]episode_index_list = []reward_list = []length_list = []while num_episodes > 0:if epsilon > 0.1:epsilon -= 0.01episode_index_list.append(init_num - num_episodes)done = Falseself.env.reset()next_state = 0total_rewards = 0episode_length = 0num_episodes -= 1while not done:state = next_stateaction = np.random.choice(np.arange(self.action_space_size),p=self.policy[state])_, reward, done, _, _ = self.env.step(action)next_state = self.env.pos2state(self.env.agent_location)expected_qvalue = 0episode_length += 1total_rewards += rewardfor next_action in range(self.action_space_size):expected_qvalue += self.qvalue[next_state, next_action] * self.policy[next_state, next_action]target = reward + self.gama * expected_qvalueerror =  target - self.qvalue[state, action]self.qvalue[state, action] = self.qvalue[state, action] + alpha * errorqvalue_star = self.qvalue[state].max()action_star = self.qvalue[state].tolist().index(qvalue_star)for a in range(self.action_space_size):if a == action_star:self.policy[state, a] = 1 - (self.action_space_size - 1) / self.action_space_size * epsilonelse:self.policy[state, a] = 1 / self.action_space_size * epsilonqvalue_list.append(self.qvalue.copy())reward_list.append(total_rewards)length_list.append(episode_length)fig = plt.figure(figsize=(10, 10))self.env.render_.add_subplot_to_fig(fig=fig, x=episode_index_list, y=reward_list, subplot_position=211,xlabel='episode_index', ylabel='total_reward')self.env.render_.add_subplot_to_fig(fig=fig, x=episode_index_list, y=length_list, subplot_position=212,xlabel='episode_index', ylabel='total_length')fig.show()def show_policy(self):# 可視化策略(Policy):將智能體的策略(每次行動的方向標注為箭頭)以圖形化的方式渲染到環境中for state in range(self.state_space_size):for action in range(self.action_space_size):policy = self.policy[state, action]self.env.render_.draw_action(pos=self.env.state2pos(state),toward=policy * 0.4 * self.env.action_to_direction[action],radius=policy * 0.1)def show_state_value(self, state_value, y_offset=0.2):# 可視化狀態價值函數(State - ValueFunction):將每個狀態的價值(長期累積獎勵的預期)以文本形式渲染到環境中。for state in range(self.state_space_size):self.env.render_.write_word(pos=self.env.state2pos(state), word=str(round(state_value[state], 1)),y_offset=y_offset,size_discount=0.7)if __name__ == "__main__":env = grid_env.GridEnv(size=5, target=[2, 3],forbidden=[[2, 2], [2, 1], [1, 1], [3, 3], [1, 3], [1, 4]],render_mode='')solver = Solve(env)solver.expected_sarsa()solver.show_policy()solver.show_state_value(solver.state_value, y_offset=0.25)solver.env.render()

效果

4)TD learning of action values: n-step Sarsa

核心思想

n - step Sarsa 是 Sarsa 算法的擴展,它不僅僅考慮下一個時間步的信息,而是考慮未來?n?個時間步的獎勵和狀態。這種方法結合了短期和長期的信息,以更準確地估計動作價值。
算法公式

特點

  • 平衡短期和長期信息:通過調整?n?的值,可以在短期和長期獎勵之間進行權衡。當?(n = 1)?時,n - step Sarsa 退化為普通的 Sarsa 算法;當?n?趨近于無窮大時,它類似于蒙特卡羅方法。
  • 可以提高學習的穩定性和效率,尤其是在環境動態變化的情況下。

偽代碼

和Sarsa類似,只是在 Q 值更新時使用的上述公式。

實現代碼

import matplotlib.pyplot as plt
import numpy as np
import grid_envclass Solve:def __init__(self, env: grid_env.GridEnv):self.gama = 0.9   #折扣因子,表示未來獎勵的衰減程度self.env = envself.action_space_size = env.action_space_size   #動作空間大小self.state_space_size = env.size ** 2     #狀態空間大小self.reward_space_size, self.reward_list = len(self.env.reward_list), self.env.reward_list   #獎勵self.state_value = np.zeros(shape=self.state_space_size)      #狀態值self.qvalue = np.zeros(shape=(self.state_space_size, self.action_space_size))    #動作值self.mean_policy = np.ones(shape=(self.state_space_size, self.action_space_size)) / self.action_space_size   #平均策略,表示采取每個動作概率相等self.policy = self.mean_policy.copy()def nsteps_sarsa(self, alpha=0.1, epsilon=1, num_episodes=1000, n=10):init_num = num_episodesqvalue_list = [self.qvalue.copy()]episode_index_list = []reward_list = []length_list = []while num_episodes > 0:if epsilon > 0.1:epsilon -= 0.01episode_index_list.append(init_num - num_episodes)done = Falseself.env.reset()next_state = 0total_rewards = 0episode_length = 0num_episodes -= 1# 存儲軌跡信息(狀態、動作、獎勵)trajectory = []while not done:state = next_stateaction = np.random.choice(np.arange(self.action_space_size), p=self.policy[state])_, reward, done, _, _ = self.env.step(action)next_state = self.env.pos2state(self.env.agent_location)trajectory.append((state, action, reward))total_rewards += rewardepisode_length += 1# 計算 n-step 回報T = len(trajectory) # 軌跡長度for t in range(T):# 獲取當前狀態、動作、獎勵state, action, reward = trajectory[t]target = 0# 計算 n-step 回報if t + n < T:# 如果軌跡足夠長,計算 n-step 回報for i in range(n-1,-1,-1):next_reward_n = trajectory[t + i][2]target = target*self.gama + next_reward_nnext_state_n = trajectory[t + n][0]next_action_n = trajectory[t + n][1]q_next = self.qvalue[next_state_n, next_action_n]target = target + q_nextelse:for i in range(T-t-1,-1,-1):next_reward_n = trajectory[t + i][2]target = target * self.gama + next_reward_nnext_state_n = trajectory[T-t-1][0]next_action_n = trajectory[T-t-1][1]q_next = self.qvalue[next_state_n, next_action_n]target = target + q_next# 更新 Q 值error = target - self.qvalue[state, action]self.qvalue[state, action] += alpha * error# 更新策略qvalue_star = self.qvalue[state].max()action_star = self.qvalue[state].tolist().index(qvalue_star)for a in range(self.action_space_size):if a == action_star:self.policy[state, a] = 1 - (self.action_space_size - 1) / self.action_space_size * epsilonelse:self.policy[state, a] = 1 / self.action_space_size * epsilonqvalue_list.append(self.qvalue.copy())reward_list.append(total_rewards)length_list.append(episode_length)fig = plt.figure(figsize=(10, 10))self.env.render_.add_subplot_to_fig(fig=fig, x=episode_index_list, y=reward_list, subplot_position=211,xlabel='episode_index', ylabel='total_reward')self.env.render_.add_subplot_to_fig(fig=fig, x=episode_index_list, y=length_list, subplot_position=212,xlabel='episode_index', ylabel='total_length')fig.show()def show_policy(self):# 可視化策略(Policy):將智能體的策略(每次行動的方向標注為箭頭)以圖形化的方式渲染到環境中for state in range(self.state_space_size):for action in range(self.action_space_size):policy = self.policy[state, action]self.env.render_.draw_action(pos=self.env.state2pos(state),toward=policy * 0.4 * self.env.action_to_direction[action],radius=policy * 0.1)def show_state_value(self, state_value, y_offset=0.2):# 可視化狀態價值函數(State - ValueFunction):將每個狀態的價值(長期累積獎勵的預期)以文本形式渲染到環境中。for state in range(self.state_space_size):self.env.render_.write_word(pos=self.env.state2pos(state), word=str(round(state_value[state], 1)),y_offset=y_offset,size_discount=0.7)if __name__ == "__main__":env = grid_env.GridEnv(size=5, target=[2, 3],forbidden=[[2, 2], [2, 1], [1, 1], [3, 3], [1, 3], [1, 4]],render_mode='')solver = Solve(env)solver.nsteps_sarsa()solver.show_policy()solver.show_state_value(solver.state_value, y_offset=0.25)solver.env.render()

效果

5)TD learning of optimal action values: Q-learning

核心思想

Q - learning 是一種異策略(off - policy)的 TD 算法,直接學習最優動作價值函數Q*(s, a)。異策略意味著它使用一個行為策略來生成行為,而使用另一個目標策略(通常是貪心策略)來更新動作價值。

算法公式:

偽代碼

1)在線版本的Q-learning(on-policy)

對于每一個 episode,執行以下操作:

如果當前狀態st? 不是目標狀態,執行以下步驟:

經驗收集(Collect the experience)

獲取經驗元組(st?,at?,rt+1?,st+1?):

具體來說,按照當前策略πt?(st?) 選擇并執行動作at?,得到獎勵rt+1? 和下一狀態 st+1?。

Q 值更新(Update q-value):按照上述公式

策略更新(Update policy):用ε 貪婪策略

2)離線版本的Q-learning(off-policy)

對于由行為策略 πb? 生成的每一個 episode {s0?,a0?,r1?,s1?,a1?,r2?,…},執行以下操作:

對于該 episode 中的每一步t=0,1,2,…,執行以下操作:

Q 值更新(Update q-value):按照上述公式

策略更新(Update policy):用貪婪策略

實現代碼

import matplotlib.pyplot as plt
import numpy as np
import grid_envclass Solve:def __init__(self, env: grid_env.GridEnv):self.gama = 0.9   #折扣因子,表示未來獎勵的衰減程度self.env = envself.action_space_size = env.action_space_size   #動作空間大小self.state_space_size = env.size ** 2     #狀態空間大小self.reward_space_size, self.reward_list = len(self.env.reward_list), self.env.reward_list   #獎勵self.state_value = np.zeros(shape=self.state_space_size)      #狀態值self.qvalue = np.zeros(shape=(self.state_space_size, self.action_space_size))    #動作值self.mean_policy = np.ones(shape=(self.state_space_size, self.action_space_size)) / self.action_space_size   #平均策略,表示采取每個動作概率相等self.policy = self.mean_policy.copy()def q_learning_on_policy(self, alpha=0.001, epsilon=0.4, num_episodes=1000):init_num = num_episodesqvalue_list = [self.qvalue, self.qvalue + 1]episode_index_list = []reward_list = []length_list = []while num_episodes > 0:episode_index_list.append(init_num - num_episodes)done = Falseself.env.reset()next_state = 0total_rewards = 0episode_length = 0num_episodes -= 1while not done:state = next_stateaction = np.random.choice(np.arange(self.action_space_size),p=self.policy[state])_, reward, done, _, _ = self.env.step(action)next_state = self.env.pos2state(self.env.agent_location)episode_length += 1total_rewards += rewardnext_qvalue_star = self.qvalue[next_state].max()target = reward + self.gama * next_qvalue_starerror = self.qvalue[state, action] - targetself.qvalue[state, action] = self.qvalue[state, action] - alpha * errorqvalue_star = self.qvalue[state].max()action_star = self.qvalue[state].tolist().index(qvalue_star)for a in range(self.action_space_size):if a == action_star:self.policy[state, a] = 1 - (self.action_space_size - 1) / self.action_space_size * epsilonelse:self.policy[state, a] = 1 / self.action_space_size * epsilonqvalue_list.append(self.qvalue.copy())reward_list.append(total_rewards)length_list.append(episode_length)fig = plt.figure(figsize=(10, 10))self.env.render_.add_subplot_to_fig(fig=fig, x=episode_index_list, y=reward_list, subplot_position=211,xlabel='episode_index', ylabel='total_reward')self.env.render_.add_subplot_to_fig(fig=fig, x=episode_index_list, y=length_list, subplot_position=212,xlabel='episode_index', ylabel='total_length')fig.show()def q_learning_off_policy(self, alpha=0.01, num_episodes=1000, episode_length=1000):qvalue_list = [self.qvalue, self.qvalue + 1]episode_index_list = []reward_list = []length_list = []init_num = num_episodeswhile num_episodes > 0:num_episodes -= 1total_rewards = 0episode_index_list.append(init_num - num_episodes)start_state = self.env.pos2state(self.env.agent_location)start_action = np.random.choice(np.arange(self.action_space_size),p=self.mean_policy[start_state])episode = self.obtain_episode(self.mean_policy.copy(), start_state=start_state, start_action=start_action,length=episode_length)for step in range(len(episode) - 1):reward = episode[step]['reward']state = episode[step]['state']action = episode[step]['action']next_state = episode[step + 1]['state']next_qvalue_star = self.qvalue[next_state].max()target = reward + self.gama * next_qvalue_starerror = self.qvalue[state, action] - targetself.qvalue[state, action] = self.qvalue[state, action] - alpha * erroraction_star = self.qvalue[state].argmax()self.policy[state] = np.zeros(self.action_space_size)self.policy[state][action_star] = 1total_rewards += rewardqvalue_list.append(self.qvalue.copy())reward_list.append(total_rewards)length_list.append(len(episode))fig = plt.figure(figsize=(10, 10))self.env.render_.add_subplot_to_fig(fig=fig, x=episode_index_list, y=reward_list, subplot_position=211,xlabel='episode_index', ylabel='total_reward')fig.show()def obtain_episode(self, policy, start_state, start_action, length):f""":param policy: 由指定策略產生episode:param start_state: 起始state:param start_action: 起始action:param length: episode 長度:return: 一個 state,action,reward,next_state,next_action 序列"""self.env.agent_location = self.env.state2pos(start_state)episode = []next_action = start_actionnext_state = start_statewhile length > 0:length -= 1state = next_stateaction = next_action_, reward, done, _, _ = self.env.step(action)next_state = self.env.pos2state(self.env.agent_location)next_action = np.random.choice(np.arange(len(policy[next_state])),p=policy[next_state])episode.append({"state": state, "action": action, "reward": reward, "next_state": next_state,"next_action": next_action})return episodedef show_policy(self):# 可視化策略(Policy):將智能體的策略(每次行動的方向標注為箭頭)以圖形化的方式渲染到環境中for state in range(self.state_space_size):for action in range(self.action_space_size):policy = self.policy[state, action]self.env.render_.draw_action(pos=self.env.state2pos(state),toward=policy * 0.4 * self.env.action_to_direction[action],radius=policy * 0.1)def show_state_value(self, state_value, y_offset=0.2):# 可視化狀態價值函數(State - ValueFunction):將每個狀態的價值(長期累積獎勵的預期)以文本形式渲染到環境中。for state in range(self.state_space_size):self.env.render_.write_word(pos=self.env.state2pos(state), word=str(round(state_value[state], 1)),y_offset=y_offset,size_discount=0.7)if __name__ == "__main__":env = grid_env.GridEnv(size=5, target=[2, 3],forbidden=[[2, 2], [2, 1], [1, 1], [3, 3], [1, 3], [1, 4]],render_mode='')solver = Solve(env)# solver.q_learning_on_policy()solver.q_learning_off_policy()solver.show_policy()solver.show_state_value(solver.state_value, y_offset=0.25)solver.env.render()

效果

1)在線版本的Q-learning

2)離線版本的Q-learning(off-policy)

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

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

相關文章

AE/PR模板 100個現代文字標題動態排版效果動畫 Motion Titles

Motion Titles是一個令人驚艷的AE/PR模板&#xff0c;提供了100個現代文字標題的動態排版效果動畫。這些動畫效果能夠為你的項目增添視覺沖擊力和專業感&#xff0c;為文字標題注入活力和動感。該模板適用于Adobe After Effects CC或更高版本以及Adobe Premiere Pro 2020或更高…

【AI提示詞】二八法則專家

提示說明 精通二八法則&#xff08;帕累托法則&#xff09;的廣泛應用&#xff0c;擅長將其應用于商業、管理、個人發展等領域&#xff0c;深入理解其在不同場景中的具體表現和實際意義。 提示詞 # Role: 二八法則專家## Profile - language: 中文 - description: 精通二八法…

前端八股 CSS 1

盒子模型 進行布局時將所有元素表示為一個個盒子box padding margin border content content&#xff1a;盒子內容 待顯示的文本和圖像 padding&#xff1a;內邊距&#xff0c;內容和border之間的空間&#xff0c;不能為負數&#xff0c;受bkc影響 border:邊框&#xff0c…

組件通信-$attrs

概述&#xff1a;$attrs用于實現當前組件的父組件&#xff0c;向當前組件的子組件通信&#xff08;爺→孫&#xff09;。 具體說明&#xff1a;$attrs是一個對象&#xff0c;包含所有父組件傳入的標簽屬性。 注意&#xff1a;$attrs會自動排除props中聲明的屬性(可以認為聲明過…

jdk開啟https詳細步驟

要在 JDK 中啟用 HTTPS&#xff0c;您可以按照以下詳細步驟進行操作&#xff1a; 生成密鑰庫和證書&#xff1a; 首先&#xff0c;您需要生成一個密鑰庫&#xff08;keystore&#xff09;和證書&#xff0c;可以使用 keytool 工具來生成。以下是使用 keytool 生成密鑰庫和證書的…

文章四《深度學習核心概念與框架入門》

文章4&#xff1a;深度學習核心概念與框架入門——從大腦神經元到手寫數字識別的奇幻之旅 引言&#xff1a;給大腦裝個"GPU加速器"&#xff1f; 想象一下&#xff0c;你的大腦如果能像智能手機的GPU一樣快速處理信息會怎樣&#xff1f;這正是深度學習的終極目標&…

關于CSDN創作的常用模板內容

&#x1f91f;致敬讀者 &#x1f7e9;感謝閱讀&#x1f7e6;笑口常開&#x1f7ea;生日快樂?早點睡覺 &#x1f4d8;博主相關 &#x1f7e7;博主信息&#x1f7e8;博客首頁&#x1f7eb;專欄推薦&#x1f7e5;活動信息 文章目錄 好文評論新文推送 &#x1f4c3;文章前言 &…

linux的信號量初識

Linux下的信號量(Semaphore)深度解析 在多線程或多進程并發編程的領域中&#xff0c;確保對共享資源的安全訪問和協調不同執行單元的同步至關重要。信號量&#xff08;Semaphore&#xff09;作為經典的同步原語之一&#xff0c;在 Linux 系統中扮演著核心角色。本文將深入探討…

《Android 應用開發基礎教程》——第十一章:Android 中的圖片加載與緩存(Glide 使用詳解)

目錄 第十一章&#xff1a;Android 中的圖片加載與緩存&#xff08;Glide 使用詳解&#xff09; &#x1f539; 11.1 Glide 簡介 &#x1f538; 11.2 添加 Glide 依賴 &#x1f538; 11.3 基本用法 ? 加載網絡圖片到 ImageView&#xff1a; ? 加載本地資源 / 文件 / UR…

AE模板 300個故障干擾損壞字幕條標題動畫視頻轉場預設

這個AE模板提供了300個故障干擾損壞字幕條標題動畫視頻轉場預設&#xff0c;讓您的視頻具有炫酷的故障效果。無論是預告片、宣傳片還是其他類型的視頻&#xff0c;這個模板都能帶給您令人驚嘆的故障運動標題效果。該模板無需任何外置插件或腳本&#xff0c;只需一鍵點擊即可應用…

在 Python 中,以雙下劃線開頭和結尾的函數(如 `__str__`、`__sub__` 等)

在 Python 中&#xff0c;以雙下劃線開頭和結尾的函數&#xff08;如 __str__、__sub__ 等&#xff09;被稱為特殊方法&#xff08;Special Methods&#xff09;或魔術方法&#xff08;Magic Methods&#xff09;。它們確實是 Python 內置的&#xff0c;用于定義類的行為&#…

git問題記錄-如何切換歷史提交分支,且保留本地修改

問題記錄 我在本地編寫了代碼&#xff0c;突然想查看之前提交的代碼&#xff0c;并且想保留當前所在分支所做的修改 通過git stash對本地的代碼進行暫存 使用git checkout <commit-hash>切換到之前的提交記錄。 查看完之后我想切換回來&#xff0c;恢復暫存的本地代碼…

Github開通第三方平臺OAuth登錄及Java對接步驟

調研起因&#xff1a; 準備搞AI Agent海外項目&#xff0c;有相當一部分用戶群體是程序員&#xff0c;所以當然要接入Github這個全球最大的同性交友網站了&#xff0c;讓用戶使用Github賬號一鍵完成注冊或登錄。 本教程基于Web H5界面進行對接&#xff0c;同時也提供了spring-…

期刊、出版社、索引數據庫

image 1、研究人員向期刊或者會議投稿&#xff0c;交注冊費和相應的審稿費等相關費用[1]&#xff1b; 2、會議組織者和期刊聯系出版社&#xff0c;交出版費用&#xff1b; 3、出版社將論文更新到自己的數據庫中&#xff0c;然后將數據庫賣給全世界各大高校或企業&#xff1b; 4…

Transformer 模型及深度學習技術應用

近年來&#xff0c;隨著卷積神經網絡&#xff08;CNN&#xff09;等深度學習技術的飛速發展&#xff0c;人工智能迎來了第三次發展浪潮&#xff0c;AI技術在各行各業中的應用日益廣泛。 注意力機制&#xff1a;理解其在現代深度學習中的關鍵作用&#xff1b; Transformer模型…

zynq7035的arm一秒鐘最多可以支持觸發多少次中斷

一、概述 1.關于zynq7035的ARM處理器一秒能夠支持多少次中斷觸發&#xff0c;需要綜合來考慮。需要確定ARM處理器的參數&#xff0c;目前zynq7000系列&#xff0c;使用的雙核Cortex-A9處理器。其中主頻大概在500MHZ~1GHZ左右&#xff0c;不同的用戶配置的主頻可能稍微有差別。 …

數據結構與算法:圖論——最短路徑

最短路徑 先給出一些leetcode算法題&#xff0c;以后遇見了相關題目再往上增加 最短路徑的4個常用算法是Floyd、Bellman-Ford、SPFA、Dijkstra。不同應用場景下&#xff0c;應有選擇地使用它們&#xff1a; 圖的規模小&#xff0c;用Floyd。若邊的權值有負數&#xff0c;需要…

[android]MT6835 Android 關閉selinux方法

Selinux SELinux is an optional feature of the Linux kernel that provides support to enforce access control security policies to enforce MAC. It is based on the LSM framework. Working with SELinux on Android – LineageOS Android 關閉selinux MT6835 Android…

【Linux網絡編程】http協議的狀態碼,常見請求方法以及cookie-session

本文專欄&#xff1a;Linux網絡編程 目錄 一&#xff0c;狀態碼 重定向狀態碼 1&#xff0c;永久重定向&#xff08;301 Moved Permanently&#xff09; 2&#xff0c;臨時重定向&#xff08;302 Found&#xff09; 二&#xff0c;常見請求方法 1&#xff0c;HTTP常見Hea…

當神經網絡突破摩爾定律:探索大模型時代的算力新紀元

當摩爾定律熄滅后&#xff1a;AI算力革命如何重塑技術文明的底層邏輯 一、摩爾定律的黃昏&#xff1a;物理極限與經濟理性的雙重困境 當英特爾在1965年提出摩爾定律時&#xff0c;沒有人預料到這個每18-24個月將芯片晶體管數量翻倍的預言會成為現代計算文明的基石。半個世紀以…