def init_viewer(dataset, rows, cols):
 m = (rows * cols)
 vis_batch = dataset.get_batch_topo(m)
 (_, patch_rows, patch_cols, channels) = vis_batch.shape
 assert (_ == m)
 mapback = hasattr(dataset, 'mapback_for_viewer')
 pv = PatchViewer((rows, (cols * (1 + mapback))), (patch_rows, patch_cols), is_color=(channels == 3))
 return pv

def init_viewer ( dataset , rows , cols ) : m = ( rows * cols ) vis_batch = dataset . get_batch_topo ( m ) ( _ , patch_rows , patch_cols , channels ) = vis_batch . shape assert ( _ == m ) mapback = hasattr ( dataset , 'mapback_for_viewer' ) pv = PatchViewer ( ( rows , ( cols * ( 1 + mapback ) ) ) , ( patch_rows , patch_cols ) , is_color = ( channels == 3 ) ) return pv
initialisation of the patchviewer with given rows and columns .