def evaluateNLL(self, dataset, labels, batch_size = 200):
"""
Evaluate likelihood of dataset
"""
nll = 0
start_time = time.time()
N = dataset.shape[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)
Y = labels[st_idx:end_idx][:,None].astype(config.floatX)
batch_nll = self.evaluate(X=X, Y=Y)
nll += batch_nll
self._p(('\tBnum:%d, Batch Bound: %.4f')%(bnum,batch_nll/float(X.shape[0])))
nll /= float(X.shape[0])
end_time = time.time()
self._p(('(Evaluation) NLL: %.4f [Took %.4f seconds]')%(nll,end_time-start_time))
return nll
评论列表
文章目录