小编Ber*_*and的帖子

R:带方向箭头的矩阵

我试图用 R 重现 Sutton 和 Barto(2018 年)中描述的算法,但我无法像作者在第 65 页上描述的那样生成带有箭头的矩阵:

在此处输入图片说明

为此,我尝试使用包“字段”,但没有取得多大成功。

在 Python 中,Shangtong Zhang 和 Kenta Shimada 提出的解决方案依赖于使用箭头符号: ACTIONS_FIGS=[ '?', '?', '?', '?'] 但这对 R 来说效果不佳......

编辑:我对初始动作进行编码,动作以数字方式更新如下:

library(data.table)
action_random = data.table(cell=c(1:25))
action_random$action_up = action_random$action_right = action_random$action_down =
action_random$action_left = rep(1,25)
action_random$proba = rep(1/4,25)
action_random
Run Code Online (Sandbox Code Playgroud)

我还能够调整此处发布的代码,以绘制带有简单箭头的简单网格:

arrows = matrix(c("\U2190","\U2191","\U2192","\U2193"),nrow=2,ncol=2)
grid_arrows = expand.grid(x=1:ncol(arrows),y=1:nrow(arrows))
grid_arrows$val = arrows[as.matrix(grid_arrows[c('y','x')])]

library(ggplot2)

ggplot(grid_arrows, aes(x=x, y=y, label=val)) + 
  geom_tile(fill='transparent', colour = 'black') + 
  geom_text(size = 14) + 
  scale_y_reverse() +
  theme_classic() + 
  theme(axis.text  = element_blank(),
        panel.grid = …
Run Code Online (Sandbox Code Playgroud)

symbols r reinforcement-learning

1
推荐指数
1
解决办法
251
查看次数

标签 统计

r ×1

reinforcement-learning ×1

symbols ×1