teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

edit

2018/03/21 02:47

投稿

mkgrei
mkgrei

スコア8562

answer CHANGED
@@ -11,4 +11,43 @@
11
11
 
12
12
  おまけ
13
13
  環境に依存して取れるactionを動的に変更する方法(の参考になるかも)。
14
- https://stackoverflow.com/questions/45001361/open-ai-enviroment-with-changing-action-space-after-each-step
14
+ https://stackoverflow.com/questions/45001361/open-ai-enviroment-with-changing-action-space-after-each-step
15
+
16
+ ---
17
+
18
+ 編集後について
19
+
20
+ ```python
21
+ self._shape = (11, 5)
22
+ self.observation_space = gym.spaces.Box(low=0,
23
+ high=1,
24
+ shape=self._shape)
25
+ ```
26
+ は正しいです。
27
+
28
+ ステップ関数はステップの場所というパラメータが1つあります。
29
+
30
+ ```python
31
+ def step(x, t=0.5):
32
+ if x > 0.5:
33
+ return 1
34
+ else:
35
+ return 0
36
+ np_step = np.vectorize(step)
37
+ ```
38
+
39
+ numpy.arrayを一気に操作したいのなら上のような関数を作ると見通しがいいです。
40
+
41
+ ```python
42
+ arr = np.array(arr)
43
+ arr[arr>0.5] = 1
44
+ arr[arr<=0.5] = 0
45
+ ```
46
+ でもできますが。
47
+ いろいろ書く方法があります。
48
+
49
+ サンプルであるせいかもしれませんが、状態が無から生成されているようになっています。
50
+ 強化学習は「前状態」→「操作」→「後状態」、
51
+ になるので、前状態と操作に依存して遷移先の後状態が決まるはずです。
52
+ 前状態からの差分操作を定義しないとポリシーがうまく学習できないかもしれません。
53
+ サンプルなので、そのように書いているだけかもしれませんが、一応気になったので。

1

edit

2018/03/21 02:47

投稿

mkgrei
mkgrei

スコア8562

answer CHANGED
@@ -2,7 +2,7 @@
2
2
  整数値も強制しています。
3
3
 
4
4
  ```python
5
- self._shape = (3, 3)
5
+ self._shape = (11, 5, 3)
6
6
  self.observation_space = gym.spaces.Box(low=0,
7
7
  high=1,
8
8
  shape=self._shape,