■ random_normal 함수를 사용해 정규 분포를 구하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import matplotlib.pyplot as pp import tensorflow as tf tensor = tf.random_normal([100], mean = 0, stddev = 2, dtype = tf.float32) with tf.Session() as session: print(tensor.eval()) pp.hist(tensor.eval(), density = True) pp.show() [결과] [-3.440956 2.9528139 -2.1874828 1.1655606 1.9633586 2.534135 2.2539172 4.1552515 0.6079847 -1.2589507 -2.3669343 2.4858336 -2.7820125 -0.35739782 1.0026959 -3.414314 -4.110763 -3.772042 -0.86982745 -3.5725734 -4.133035 -0.6590802 1.6426448 -2.18655 1.7955924 0.6521051 -1.4494358 -1.393985 1.1428603 -3.6488476 -0.5809621 1.120533 0.7422741 -1.8246961 2.0381367 -0.5463194 -3.0208485 -1.3748398 4.41915 -1.430362 0.74772584 -0.41407225 2.5688095 1.7374964 -0.21328539 0.24921085 0.8804999 0.07990843 -1.261807 0.953815 -2.9196105 -2.6247299 0.21441022 1.5979617 -1.3157839 1.2904466 0.2824374 2.3852978 -2.2696433 2.0548098 0.52727544 -3.3213265 2.102399 4.7985563 1.384564 -2.1308424 -0.13864219 -2.6747816 3.0806332 -2.369708 -1.4581449 -0.15420328 1.621943 0.12209347 -2.8875623 1.6283735 1.9554224 -1.6151962 2.5842354 2.6196551 -1.6083497 -0.73591906 -3.3242385 1.4458559 -0.16545773 0.06856316 2.8434432 -0.9933967 0.73452926 -1.2012529 -3.075046 -0.9778303 2.856141 1.1595836 -1.6699845 3.2019432 1.0307454 2.7444181 -1.1426736 -0.41676688] |