#NEWLINE# def compute_log_ais_weights( batch_size , free_energy_fn , sample_fn , betas ) : #NEWLINE# #INDENT# '\n    Compute log of the AIS weights\n\n    Parameters\n    ----------\n    batch_size : scalar\n        Size of a batch of samples\n    free_energy_fn : theano.function\n        Function which, given temperature beta_k, computes the free energy\n        of the samples stored in model.samples. This function should return\n        a symbolic vector.\n    sample_fn : theano.function\n        Function which, given temperature beta_k, generates samples h1 ~\n        p_k(h1).\n    betas : array-like object of scalars\n        Inverse temperature parameters for which to compute the log_ais weights\n\n    Returns\n    -------\n    log_ais_w : theano.tensor.vector\n        Vector containing log ais-weights\n    ' #NEWLINE# log_ais_w = numpy . zeros ( batch_size , dtype = floatX ) #NEWLINE# for i in range ( ( len ( betas ) - 1 ) ) : #NEWLINE# #INDENT# ( bp , bp1 ) = ( betas [ i ] , betas [ ( i + 1 ) ] ) #NEWLINE# log_ais_w += ( free_energy_fn ( bp ) - free_energy_fn ( bp1 ) ) #NEWLINE# sample_fn ( bp1 ) #NEWLINE# if ( ( i % 1000.0 ) == 0 ) : #NEWLINE# #INDENT# logging . info ( ( 'Temperature %f ' % bp1 ) ) #NEWLINE# #UNINDENT# #UNINDENT# return log_ais_w