国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

【莫煩Python】強化學習 Reinforcement Learning

2023-02-05 20:25 作者:嘻嘻000001  | 我要投稿

幾種算法

不斷嘗試達到目標

import numpy as np

import pandas as pd

class qlearning_table:

def__init__(self,actions,learning_rate=0.01,reward_decay=0.9,e_greedy=0.9)

self.actions=actions

self.lr=learning_rate

self.gamma=reward_decay

self.epsilon=e_greedy

self.q_table=pd.DataFrame(columns=self.actions)


def choose_action(self,observation):

self.check_state_exist(observation)


#choose action selection

np.random.uniform()<self.epsilon:

#choose best action

state_action=self.q_table.ix[observation,:]

state_action=state_action.reindex(np.random.permutation(state_action.index))

action=state_action.argmax()

else:

action=np.random.choice(self.action)

return action

def learn(self,s,a,r,s_):

self.check_state_exist(s_)

q_predict=self.q_table.ix[s,a]

if s_ !='terminal':

q_target=r+self.gamma*self.q_table

else:

q_target=r#next state is terminal

self.q_table.ix[s,a]+=self.lr*(q_target-q_predict)#update

def check_state_exist(self,state):

if state not in self.q_table.append(

pd.Series(

[0]*len(self.action),

index=self.q_table.columns,

name=state,))























def check_state_exist(self,state):



【莫煩Python】強化學習 Reinforcement Learning的評論 (共 條)

分享到微博請遵守國家法律
合肥市| 宁德市| 曲麻莱县| 绍兴市| 繁峙县| 长阳| 沙湾县| 太仆寺旗| 定兴县| 安乡县| 平远县| 双流县| 泰顺县| 六枝特区| 巴青县| 景洪市| 高陵县| 深泽县| 崇仁县| 威信县| 丹棱县| 枝江市| 广宁县| 武城县| 阜南县| 娄底市| 栖霞市| 正阳县| 铜山县| 政和县| 郧西县| 富锦市| 黄浦区| 海宁市| 成都市| 漳浦县| 绥芬河市| 苍南县| 岳池县| 嘉兴市| 焦作市|