W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
expectation( f , p , z = none, n = none, seed = none, name = 'expectation' )
定義在tensorflow/contrib/bayesflow/python/ops/monte_carlo_impl.py.
參見指南:貝葉斯蒙特卡羅(contrib)>行動(dòng)
蒙特卡羅估計(jì)的期望:E_p[f(Z)] 與樣本具有均值.
該操作返回:
n ^ { - 1 } sum_ {i= 1 } ^ n f( z_i ),where z_i ? p \approx E_p[f(Z)]
與一個(gè) Tensor 具有相同 dtype 的 p,舉例:
N_samples = 10000 distribute = tf.contrib.distributions dist =distributions.Uniform([ 0.0,0.0 ] ,[1.0,2.0]) elementwise_mean = lambda x :x mean_sum = lambda x : tf.reduce_sum(x ,1) estimate_elementwise_mean_tf = monte_carlo.expectation( elementwise_mean , dist , n = N_samples ) estimate_mean_sum_tf = monte_carlo.expectation( mean_sum , dist , n = N_samples ) with tf.Session()as sess : estimate_elementwise_mean , estimate_mean_sum = ( sess.run([estimate_elementwise_mean_tf ,estimate_mean_sum_tf])) print estimate_elementwise_mean >>> np.array([0.50018013 1.00097895 ] ,dtype=np. float32 ) print estimate_mean_sum >>> 1.49571
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: