How to use the deepdish.io.load function in deepdish

To help you get started, we’ve selected a few deepdish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uchicago-cs / deepdish / deepdish / io / ls.py View on Github external
welcome = "Loaded {} into '{}':".format(
            path_desc,
            paint('data', 'blue', colorize=colorize))

        # Import deepdish for the session
        import deepdish as dd
        import IPython
        IPython.embed(header=welcome)

    i = 0
    if args.inspect is not None:
        fn = single_file(args.file)

        try:
            data = io.load(fn, args.inspect)
        except ValueError:
            s = 'Error: Could not find group: {}'.format(args.inspect)
            print(paint(s, 'red', colorize=colorize))
            sys.exit(1)
        if args.ipython:
            run_ipython(fn, group=args.inspect, data=data)
        else:
            print(data)
    elif args.ipython:
        fn = single_file(args.file)
        data = io.load(fn)
        run_ipython(fn, data=data)
    else:
        for f in args.file:
            # State that will be incremented
            settings['filtered_count'] = 0
github uchicago-cs / deepdish / deepdish / io / ls.py View on Github external
if args.inspect is not None:
        fn = single_file(args.file)

        try:
            data = io.load(fn, args.inspect)
        except ValueError:
            s = 'Error: Could not find group: {}'.format(args.inspect)
            print(paint(s, 'red', colorize=colorize))
            sys.exit(1)
        if args.ipython:
            run_ipython(fn, group=args.inspect, data=data)
        else:
            print(data)
    elif args.ipython:
        fn = single_file(args.file)
        data = io.load(fn)
        run_ipython(fn, data=data)
    else:
        for f in args.file:
            # State that will be incremented
            settings['filtered_count'] = 0

            if args.column_width is None:
                settings['left-column-width'] = max(MIN_AUTOMATIC_COLUMN_WIDTH, min(MAX_AUTOMATIC_COLUMN_WIDTH, _discover_column_width(f)))
            else:
                settings['left-column-width'] = args.column_width

            s = get_tree(f, raw=args.raw, settings=settings)
            if s is not None:
                if i > 0:
                    print()
github uchicago-cs / deepdish / deepdish / tools / caffe / plot_responses.py View on Github external
except:
                break

            y.append(np.mean(rs))
            ystd.append(np.std(rs))
        plt.errorbar(np.arange(len(y)), y, yerr=ystd, label='{}'.format(name))
        plt.xticks(np.arange(len(y)), layers)
    plt.ylabel('<- Redundancy / Identity-like ->')
    plt.legend(loc=4)
    plt.ylim((0, 1))
    plt.savefig(vz.impath('svg'))
    plt.close()

    plt.figure()
    for fn in args.responses:
        data = dd.io.load(fn)
        name = data['name']
        if layers is None:
            layers = data['layers']
        y = []
        ystd = []
        for l in layers:
            rs = []
            #for X in data['responses'][l]:
            X = data['responses'][l]

            y.append(X.mean())
        plt.plot(np.arange(len(y)), y, label='{}'.format(name))
        plt.xticks(np.arange(len(y)), layers)
    plt.ylabel('Mean')
    plt.legend(loc=4)
    plt.savefig(vz.impath('svg'))
github ContextLab / hypertools / hypertools / tools / load.py View on Github external
align : str or dict
        If str, either 'hyper' or 'SRM'.  If 'hyper', alignment algorithm will be
        hyperalignment. If 'SRM', alignment algorithm will be shared response
        model.  You can also pass a dictionary for finer control, where the 'model'
        key is a string that specifies the model and the params key is a dictionary
        of parameter values (default : 'hyper').

    Returns
    ----------
    data : Numpy Array
        Example data

    """

    if dataset[-4:] == '.geo':
        geo = dd.io.load(dataset)
        if 'dtype' in geo:
            if 'list' in geo['dtype']:
                geo['data'] = list(geo['data'])
            elif 'df' in geo['dtype']:
                geo['data'] = pd.DataFrame(geo['data'])
        geo['xform_data'] = list(geo['xform_data'])
        data = DataGeometry(**geo)
    elif dataset in datadict.keys():
        data = _load_data(dataset, datadict[dataset])
    else:
        raise RuntimeError('No data loaded. Please specify a .geo file or '
                       'one of the following sample files: weights, '
                       'weights_avg, weights_sample, spiral, mushrooms, '
                       'wiki, nips or sotus.')

    if data is not None:
github uchicago-cs / deepdish / deepdish / util / saveable.py View on Github external
def load(cls, path):
        if path is None:
            return cls.load_from_dict({})
        else:
            d = io.load(path)
            # Check class type
            class_name = d.get('name')
            if class_name is not None:
                return cls.getclass(class_name).load_from_dict(d)
            else:
                return cls.load_from_dict(d)
github gustavla / self-supervision / selfsup / evaluate / voc_classification.py View on Github external
def build_network(raw_x, y, model_filename=None, network_type='alex-lrn'):
    outputs = []
    activations = {}

    phase_test = tf.placeholder(tf.bool, name='phase_test')

    info = selfsup.info.create(scale_summary=True)

    x = raw_x - 114.451/255

    # Scale and subtract mean
    if model_filename is not None:
        data = dd.io.load(model_filename, '/data')
    else:
        data = {}

    if network_type in ['alex', 'alex-lrn']:
        use_lrn = network_type == 'alex-lrn'
        print('USE_LRN', use_lrn)
        z = selfsup.model.alex.build_network(x, info=info, parameters=data,
                                 final_layer=False,
                                 phase_test=phase_test,
                                 pre_adjust_batch_norm=True,
                                 use_lrn=use_lrn,
                                 use_dropout=True,
                                 well_behaved_size=False)
    elif network_type == 'vgg16':
        z = selfsup.model.vgg16.build_network(x, info=info, parameters=data,
                                 final_layer=False,
github KordingLab / spykes / spykes / io / datasets.py View on Github external
'''
    # Import is performed here so that deepdish is not required for all of
    # the "datasets" functions.
    import deepdish

    dpath = os.path.join(config.get_data_directory(), dir_name)
    if not os.path.exists(dpath):
        os.makedirs(dpath)

    # Downloads the file if it doesn't exist already.
    fpath = os.path.join(dpath, 'reaching_dataset.h5')
    if not os.path.exists(fpath):
        url = 'http://goo.gl/eXeUz8'
        _urlretrieve(url, fpath)

    data = deepdish.io.load(fpath)
    return data
github uchicago-cs / deepdish / deepdish / tools / caffe / plot_loss.py View on Github external
caption = loss_fn

        caption = '{} ({:.3f})'.format(caption, losses[-1])

        plt.errorbar(iter, losses, yerr=losses_std, label=caption)

    plt.legend()
    plt.ylabel('Loss')
    plt.xlabel('Iteration')
    vz.savefig()
    plt.close()

    plt.figure()
    for i, loss_fn in enumerate(args.losses):
        print('file', loss_fn)
        data = dd.io.load(loss_fn)
        iter = data['iterations'][0]
        rates = 100*(1-data['rates'].mean(0))
        rates_std = 100*data['rates'].std(0)

        if args.captions:
            caption = args.captions[i]
        else:
            caption = loss_fn

        caption = '{} ({:.2f}%)'.format(caption, rates[-1])

        plt.errorbar(iter, rates, yerr=rates_std, label=caption)

    plt.legend()
    plt.ylabel('Error rate (%)')
    plt.xlabel('Iteration')
github akanazawa / hmr / src / trainer.py View on Github external
def load_mean_param(self):
        mean = np.zeros((1, self.total_params))
        # Initialize scale at 0.9
        mean[0, 0] = 0.9
        mean_path = join(
            dirname(self.smpl_model_path), 'neutral_smpl_mean_params.h5')
        mean_vals = dd.io.load(mean_path)

        mean_pose = mean_vals['pose']
        # Ignore the global rotation.
        mean_pose[:3] = 0.
        mean_shape = mean_vals['shape']

        # This initializes the global pose to be up-right when projected
        mean_pose[0] = np.pi

        mean[0, 3:] = np.hstack((mean_pose, mean_shape))
        mean = tf.constant(mean, tf.float32)
        self.mean_var = tf.Variable(
            mean, name="mean_param", dtype=tf.float32, trainable=True)
        self.E_var.append(self.mean_var)
        init_mean = tf.tile(self.mean_var, [self.batch_size, 1])
        return init_mean