def free_energy_at_beta(W_list, b_list, samples, beta, pa_bias=None,
                        marginalize_odd=True):
    # There's as much layers in the DBM as there are bias vectors
    depth = len(b_list)

    fe = 0.

    # Contribution of biases
    keep_idx = numpy.arange(not marginalize_odd, depth, 2)
    for i in keep_idx:
        fe -= T.dot(samples[i], b_list[i]) * beta

    # Contribution of biases
    marg_idx = numpy.arange(marginalize_odd, depth, 2)
    for i in marg_idx:
        from_im1 = T.dot(samples[i-1], W_list[i]) if i >= 1 else 0.
        from_ip1 = T.dot(samples[i+1], W_list[i+1].T) if i < depth-1 else 0
        net_input = (from_im1 + from_ip1 + b_list[i]) * beta
        fe -= T.sum(T.nnet.softplus(net_input), axis=1)

    fe -= T.dot(samples[not marginalize_odd], pa_bias) * (1. - beta)

    return fe
Some method's docstring
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/scripts/dbm/dbm_metrics.py/free_energy_at_beta--crossover with--dataset/ETHPy150Open ipython/ipython-py3k/IPython/core/tests/test_oinspect.py/Call.method