五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
光山县| 南宁市| 开远市| 澄江县| 伊金霍洛旗| 石台县| 永康市| 巢湖市| 西峡县| 博湖县| 彭泽县| 醴陵市| 互助| 江安县| 惠水县| 扎鲁特旗| 永州市| 横山县| 石泉县| 建宁县| 昌都县| 怀宁县| 西峡县| 隆德县| 札达县| 鹤壁市| 安康市| 青海省| 皮山县| 吉木乃县| 芦山县| 白沙| 博客| 昔阳县| 永济市| 西乌| 开江县| 青浦区| 沾化县| 嘉荫县| 武穴市|