

def init_viewer(dataset, rows, cols, vis_batch):
    '\n    Initialisation of the PatchViewer with given rows and columns.\n\n    Parameters\n    ----------\n    dataset: pylearn2 dataset\n    rows: int\n    cols: int\n    vis_batch: numpy array\n    '
    m = (rows * cols)
    (_, patch_rows, patch_cols, channels) = vis_batch.shape
    assert (_ == m)
    mapback = hasattr(dataset, 'mapback_for_viewer')
    actual_cols = (((2 * cols) * (1 + mapback)) * (1 + (channels == 2)))
    pv = PatchViewer((rows, actual_cols), (patch_rows, patch_cols), is_color=(channels == 3))
    return pv

dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/scripts/dbm/show_reconstructions.py init_viewer/original