(filename)
return ret
Read deconv visualization data from hdf5 file.

    Arguments:
        filename (str): Filename with hdf5 deconv data

    Returns:
        list of lists. Each inner list represents one layer, and consists of
        tuples (fm, deconv_data)
Read deconv visualization data from hdf5 file.
Read deconv visualization data from hdf5 file .
def h5_deconv_data(filename):
    """
    Read deconv visualization data from hdf5 file.

    Arguments:
        filename (str): Filename with hdf5 deconv data

    Returns:
        list of lists. Each inner list represents one layer, and consists of
        tuples (fm, deconv_data)
    """
    ret = list()
    with h5py.File(filename, "r") as f:
        if 'deconv' not in list(f.keys()):
            return None
        act_data = f['deconv/max_act']
        img_data = f['deconv/img']

        for layer in list(act_data.keys()):
            layer_data = list()
            for fm in range(act_data[layer]['vis'].shape[0]):

                # to avoid storing entire dataset, imgs are cached as needed, have to look up
                batch_ind, img_ind = act_data[layer]['batch_img'][fm]
                img_store = img_data['batch_{}'.format(batch_ind)]
                img_cache_ofs = img_store.attrs[str(img_ind)]

                # have to convert from rgb to rgba and cast as uint32 dtype for bokeh
                plot_img = convert_rgb_to_bokehrgba(img_store['HWC_uint8'][:, :, :, img_cache_ofs])
                plot_deconv = convert_rgb_to_bokehrgba(act_data[layer]['vis'][fm])

                layer_data.append((fm, plot_deconv, plot_img))

            ret.append((layer, layer_data))
    return ret
def h5_deconv_data ( filename ) : ret = list ( ) with h5py . File ( filename , "r" ) as f : if 'deconv' not in list ( f . keys ( ) ) : return None act_data = f [ 'deconv/max_act' ] img_data = f [ 'deconv/img' ] for layer in list ( act_data . keys ( ) ) : layer_data = list ( ) for fm in range ( act_data [ layer ] [ 'vis' ] . shape [ 0 ] ) : # to avoid storing entire dataset, imgs are cached as needed, have to look up batch_ind , img_ind = act_data [ layer ] [ 'batch_img' ] [ fm ] img_store = img_data [ 'batch_{}' . format ( batch_ind ) ] img_cache_ofs = img_store . attrs [ str ( img_ind ) ] # have to convert from rgb to rgba and cast as uint32 dtype for bokeh plot_img = convert_rgb_to_bokehrgba ( img_store [ 'HWC_uint8' ] [ : , : , : , img_cache_ofs ] ) plot_deconv = convert_rgb_to_bokehrgba ( act_data [ layer ] [ 'vis' ] [ fm ] ) layer_data . append ( ( fm , plot_deconv , plot_img ) ) ret . append ( ( layer , layer_data ) ) return ret