質問編集履歴

2

該当するソースコードの追加

2020/04/06 23:01

投稿

teefpc
teefpc

スコア111

test CHANGED
File without changes
test CHANGED
@@ -26,28 +26,24 @@
26
26
 
27
27
 
28
28
 
29
- ⬇️5回試行た結果
29
+ multinomialを使っているので基本的には並べ替えを変えているようですが、それだけでょうか。
30
30
 
31
- ```Python
31
+ ```PyTorch
32
32
 
33
- action tensor(0)
33
+ def sample(self, sample_shape=torch.Size()):
34
34
 
35
- log_prob tensor(-0.9163)
35
+ sample_shape = self._extended_shape(sample_shape)
36
36
 
37
- action tensor(1)
37
+ param_shape = sample_shape + torch.Size((self._num_events,))
38
38
 
39
- log_prob tensor(-0.5108)
39
+ probs = self.probs.expand(param_shape)
40
40
 
41
- action tensor(1)
41
+ probs_2d = probs.reshape(-1, self._num_events)
42
42
 
43
- log_prob tensor(-0.5108)
43
+ sample_2d = torch.multinomial(probs_2d, 1, True)
44
44
 
45
- action tensor(1)
45
+ return sample_2d.reshape(sample_shape)
46
46
 
47
- log_prob tensor(-0.5108)
48
47
 
49
- action tensor(0)
50
-
51
- log_prob tensor(-0.9163)
52
48
 
53
49
  ```

1

リンク追加

2020/04/06 23:01

投稿

teefpc
teefpc

スコア111

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  ```
24
24
 
25
- この確率分布クラスは毎回サンプリング値が異なりますが、具体的に、どのような計算を行っているのしょうか。
25
+ この確率分布クラスは毎回サンプリング値が異なりますが、具体的に、どのような計算を行っているのしょうか。参考ページ[PROBABILITY DISTRIBUTIONS - TORCH.DISTRIBUTIONS](https://pytorch.org/docs/stable/distributions.html)
26
26
 
27
27
 
28
28