Path: blob/master/site/es-419/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 [ ]:
Distribuciones para aprender Zoo
En este Colab se muestran varios ejemplos de creación de distribuciones que se pueden aprender ("entrenar"). (No hacemos ningún esfuerzo por explicar las distribuciones, solo para mostrar cómo compilarlas).
In [ ]:
In [ ]:
Normal multivariante aprendible con identidad escalada para chol(Cov)
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)>)
Normal multivariante aprendible con diagonal para 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)>)
Mezcla de normal multivariante (esférica)
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)>)
Mezcla de normal multivariante (esférica) con ponderación de la primera mezcla imposible de aprender
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)>)
Mezcla de normal multivariante (Cov
completa)
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)>)
Mezcla de normal multivariante (Cov
completa) con primera mezcla y primer componente que no se pueden aprender
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)>)