- PyTorch 1.x Reinforcement Learning Cookbook
- Yuxi (Hayden) Liu
- 150字
- 2021-06-24 12:34:44
How to do it...
To create a Markov chain for the study - and - sleep process and conduct some analysis on it, perform the following steps:
- Import the library and define the transition matrix:
>>> import torch
>>> T = torch.tensor([[0.4, 0.6],
... [0.8, 0.2]])
- Calculate the transition probability after k steps. Here, we use k = 2, 5, 10, 15, and 20 as examples:
>>> T_2 = torch.matrix_power(T, 2)
>>> T_5 = torch.matrix_power(T, 5)
>>> T_10 = torch.matrix_power(T, 10)
>>> T_15 = torch.matrix_power(T, 15)
>>> T_20 = torch.matrix_power(T, 20)
- Define the initial distribution of two states:
>>> v = torch.tensor([[0.7, 0.3]])
- Calculate the state distribution after k = 1, 2, 5, 10, 15, and 20 steps:
>>> v_1 = torch.mm(v, T)
>>> v_2 = torch.mm(v, T_2)
>>> v_5 = torch.mm(v, T_5)
>>> v_10 = torch.mm(v, T_10)
>>> v_15 = torch.mm(v, T_15)
>>> v_20 = torch.mm(v, T_20)
推薦閱讀
- Machine Learning for Cybersecurity Cookbook
- 大數(shù)據(jù)專業(yè)英語
- 錯覺:AI 如何通過數(shù)據(jù)挖掘誤導(dǎo)我們
- 空間機器人遙操作系統(tǒng)及控制
- 數(shù)據(jù)中心建設(shè)與管理指南
- 手把手教你學(xué)AutoCAD 2010
- Learning Social Media Analytics with R
- Mastering Elastic Stack
- Maya極速引擎:材質(zhì)篇
- 大型數(shù)據(jù)庫管理系統(tǒng)技術(shù)、應(yīng)用與實例分析:SQL Server 2005
- 計算機系統(tǒng)結(jié)構(gòu)
- Learn Microsoft Azure
- Java求職寶典
- 互聯(lián)網(wǎng)單元測試及實踐
- Microsoft 365 Mobility and Security:Exam Guide MS-101