Пример #1
0
def try_run_experiment(config, mc_chain_name):
    """
    Put run_experiment inside a try-except so that one failed experiment
    doesn't kill them all when many are running in parallel.
    """
    try:
        run_experiment(config, mc_chain_name)
    except (KeyboardInterrupt, SystemExit):
        raise
    except Exception:
        print '%s failed' % mc_chain_name
        traceback.print_exc()
Пример #2
0
def main():
    num_args = len(sys.argv) - 1
    if num_args < 1:
        config_path = '../config.ini'
    elif num_args > 1:
        raise Exception('too many arguments: %d. %d expected' % (num_args, 1))
    else:
        config_path = sys.argv[1]
    config_file = io.abspath2(config_path)

    config = io.load_config(config_file)

    model_list = io.get_model_list(config['input_path'], config['pkl_ext'])
    # model_list = model_list[:5]  # TODO remove, test only
    assert (all(io.is_safe_name(ss) for ss in model_list))
    print 'using models:'
    print model_list

    # Sort for reprodicibility
    sampler_list = sorted(BUILD_STEP_PM.keys() + BUILD_STEP_MC.keys())
    print 'using samplers:'
    print sampler_list

    # Get the exact samples
    for model_name in model_list:
        run_experiment(config, model_name, config['exact_name'])

    # Run n_chains in the outer loop since if process get killed we have less
    # chains but with even distribution over models and samplers.
    for model_name in model_list:
        for _ in xrange(config['n_chains']):
            # TODO could put ADVI init here to keep it fixed across samplers
            for sampler in sampler_list:
                t = time()
                try:
                    run_experiment(config, model_name, sampler)
                except Exception as err:
                    print '%s/%s failed' % (model_name, sampler)
                    print str(err)
                print 'wall time %fs' % (time() - t)
    print 'done'
Пример #3
0
        glVertex3f(0.0, 0.0, 0.0)
        glVertex3f(0.0, 0.0, 1.0)
        glEnd()

    def __draw_message(self):
        """
        Draw the message or fixation point
        """
        # Draw the quadrilateral mapping it to the texture
        glDrawArrays(GL_QUADS, 0, 4)

    def __draw_model(self):
        """
        Draw the stimulus
        """
        points = (WIDTH / STEP_SIZE) * (HEIGHT / STEP_SIZE) * 4
        # If set to render solid, render the solid version
        if RENDER_SOLID:
            # Start drawing the quadrilateral
            glDrawArrays(GL_QUADS, 0, points)
        # Else produce wireframe
        else:
            # Draw lines to indicate the wireframe
            glDrawArrays(GL_LINES, 0, points)


if __name__ == '__main__':
    # Run the experiment even without running it directly from main.py
    from main import run_experiment
    run_experiment()