logistic.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:theanomodels 作者: clinicalml 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号