def get_nll(x, parzen, batch_size=10):
 inds = range(x.shape[0])
 n_batches = int(numpy.ceil((float(len(inds)) / batch_size)))
 times = []
 nlls = []
 for i in range(n_batches):
  begin = time.time()
  nll = parzen(x[inds[i::n_batches]])
  end = time.time()
  times.append((end - begin))
  nlls.extend(nll)
  if ((i % 10) == 0):
   print i, numpy.mean(times), numpy.mean(nlls)
 return numpy.array(nlls)

def get_nll ( x , parzen , batch_size = 10 ) : inds = range ( x . shape [ 0 ] ) n_batches = int ( numpy . ceil ( ( float ( len ( inds ) ) / batch_size ) ) ) times = [ ] nlls = [ ] for i in range ( n_batches ) : begin = time . time ( ) nll = parzen ( x [ inds [ i : : n_batches ] ] ) end = time . time ( ) times . append ( ( end - begin ) ) nlls . extend ( nll ) if ( ( i % 10 ) == 0 ) : print i , numpy . mean ( times ) , numpy . mean ( nlls ) return numpy . array ( nlls )
credit: yann n .