Path: blob/master/site/ko/probability/examples/Learnable_Distributions_Zoo.ipynb
25118 views
Kernel: Python 3
Copyright 2019 The TensorFlow Probability Authors.
Licensed under the Apache License, Version 2.0 (the "License");
In [ ]:
학습 가능한 분포 동물원(Zoo)
이 colab에서는 학습 가능한('훈련 가능한') 분포를 빌드하는 다양한 예를 보여줍니다. 분포를 설명하려고 하기보다는 분포를 빌드하는 방법을 보여주기 위해 노력합니다.
In [ ]:
In [ ]:
chol(Cov)
에 대한 scaled ID를 사용하는 학습 가능한 다변량 정규 분포
In [ ]:
tfp.distributions.Independent("learnable_mvn_scaled_identity", batch_shape=[], event_shape=[4], dtype=float32)
(<tf.Variable 'loc:0' shape=(4,) dtype=float32, numpy=array([0., 0., 0., 0.], dtype=float32)>, <tf.Variable 'scale:0' shape=(1,) dtype=float32, numpy=array([0.], dtype=float32)>)
chol(Cov)
에 대해 학습 가능한 대각선 다변량 정규 분포
In [ ]:
tfp.distributions.Independent("learnable_mvn_diag", batch_shape=[], event_shape=[4], dtype=float32)
(<tf.Variable 'loc:0' shape=(4,) dtype=float32, numpy=array([0., 0., 0., 0.], dtype=float32)>, <tf.Variable 'scale:0' shape=(4,) dtype=float32, numpy=array([0.54132485, 0.54132485, 0.54132485, 0.54132485], dtype=float32)>)
다변량 정규 분포(구형)의 혼합
In [ ]:
tfp.distributions.MixtureSameFamily("learnable_mix_mvn_scaled_identity", batch_shape=[], event_shape=[4], dtype=float32)
(<tf.Variable 'logits:0' shape=(3,) dtype=float32, numpy=array([-0., -0., -0.], dtype=float32)>, <tf.Variable 'loc:0' shape=(3, 4) dtype=float32, numpy=
array([[ 0.21316044, 0.18825649, 1.3055958 , -1.4072137 ],
[-1.6604203 , -0.9415946 , -1.1349488 , -0.4928658 ],
[-0.9672405 , 0.45094398, -2.615817 , 3.7891428 ]],
dtype=float32)>, <tf.Variable 'scale:0' shape=(3, 1) dtype=float32, numpy=
array([[9.999954],
[9.999954],
[9.999954]], dtype=float32)>)
학습 불가능한 첫 번째 혼합 가중치가 있는 다변량 정규 분포(구형)의 혼합
In [ ]:
tfp.distributions.MixtureSameFamily("learnable_mix_mvndiag_first_fixed", batch_shape=[], event_shape=[4], dtype=float32)
(<tf.Variable 'Variable:0' shape=(2,) dtype=float32, numpy=array([-0.4054651, -0.8109302], dtype=float32)>, <tf.Variable 'loc:0' shape=(3, 4) dtype=float32, numpy=
array([[ 1., 1., -1., -1.],
[ 1., -1., 1., 1.],
[-1., 1., -1., -1.]], dtype=float32)>, <tf.Variable 'scale:0' shape=(3, 1) dtype=float32, numpy=
array([[9.999954],
[9.999954],
[9.999954]], dtype=float32)>)
다변량 정규 분포의 혼합(전체 Cov
)
In [ ]:
tfp.distributions.MixtureSameFamily("learnable_mix_mvntril", batch_shape=[], event_shape=[4], dtype=float32)
(<tf.Variable 'loc:0' shape=(3, 4) dtype=float32, numpy=
array([[0., 0., 0., 0.],
[0., 0., 0., 0.],
[0., 0., 0., 0.]], dtype=float32)>, <tf.Variable 'scale_tril:0' shape=(3, 10) dtype=float32, numpy=
array([[9.999945, 0. , 0. , 0. , 9.999945, 9.999945,
0. , 0. , 0. , 9.999945],
[9.999945, 0. , 0. , 0. , 9.999945, 9.999945,
0. , 0. , 0. , 9.999945],
[9.999945, 0. , 0. , 0. , 9.999945, 9.999945,
0. , 0. , 0. , 9.999945]], dtype=float32)>, <tf.Variable 'logits:0' shape=(3,) dtype=float32, numpy=array([-0., -0., -0.], dtype=float32)>)
학습 불가능한 첫 번째 혼합과 첫 번째 성분이 있는 다변량 정규 분포(전체 Cov
)의 혼합
In [ ]:
tfp.distributions.MixtureSameFamily("learnable_mix_mvntril_fixed_first", batch_shape=[], event_shape=[4], dtype=float32)
(<tf.Variable 'loc:0' shape=(2, 4) dtype=float32, numpy=
array([[0., 0., 0., 0.],
[0., 0., 0., 0.]], dtype=float32)>, <tf.Variable 'scale_tril:0' shape=(2, 10) dtype=float32, numpy=
array([[9.999945, 0. , 0. , 0. , 9.999945, 9.999945,
0. , 0. , 0. , 9.999945],
[9.999945, 0. , 0. , 0. , 9.999945, 9.999945,
0. , 0. , 0. , 9.999945]], dtype=float32)>, <tf.Variable 'logits:0' shape=(2,) dtype=float32, numpy=array([-0., -0.], dtype=float32)>)