def evaluateBound(self, dataset, batch_size, S=10):
"""
Evaluate bound S times on dataset
"""
N = dataset.shape[0]
bound = 0
for bnum,st_idx in enumerate(range(0,N,batch_size)):
end_idx = min(st_idx+batch_size, N)
X = dataset[st_idx:end_idx].astype(config.floatX)
for s in range(S):
eps = np.random.randn(X.shape[0],self.params['dim_stochastic']).astype(config.floatX)
if self.params['inference_model']=='single':
batch_bound = self.evaluate(X=X, eps=eps)
else:
assert False,'Should not be here'
bound += batch_bound
bound /= float(N*S)
return bound
评论列表
文章目录