load model from file. fv_type is not set with this function. It is expected to set it before.
320758
def load(self, mdl_file):
        
        import dill as pickle

        mdl_file_e = op.expanduser(mdl_file)

        sv = pickle.load(open(mdl_file_e, "rb"))
        self.mdl = sv["mdl"]
        # self.mdl[2] = self.mdl[0]
        # try:
        #     eval(sv['fv_extern_src'])
        #     eval("fv_extern_temp_name  = " + sv['fv_extern_src_name'])
        #     sv['fv_extern'] = fv_extern_temp_name
        # except:
        #     print "pomoc,necoje blbe"
        #     pass

        self.modelparams.update(sv["modelparams"])
        logger.debug("loaded model from path: " + mdl_file_e)
1250635
def _load(content_or_fp):
    
    try:
        data = yaml.load(content_or_fp, Loader=yaml.loader.BaseLoader)
    except Exception as e:
        raise type(e)('Malformed yaml file:\n%r' % format_exc())

    try:
        ver = data['spec']
    except:
        raise ValueError('The file does not specify a spec version')

    try:
        ver = tuple(map(int, (ver.split("."))))
    except:
        raise ValueError("Invalid spec version format. Expect 'X.Y'"
                         " (X and Y integers), found %s" % ver)

    if ver > SPEC_VERSION_TUPLE:
        raise ValueError('The spec version of the file is '
                         '%s but the parser is %s. '
                         'Please update pyvisa-sim.' % (ver, SPEC_VERSION))

    return data
892387
def rtype_to_model(rtype):
    

    models = goldman.config.MODELS
    for model in models:
        if rtype.lower() == model.RTYPE.lower():
            return model
    raise ValueError('%s resource type not registered' % rtype)
114177
def load(self, f):
        
        with _open_file_obj(f) as f:
            parser = self.parse_file(f)
            self.deserialize(parser)
1075497
async def blob_load(self, elem_type, params=None, elem=None):
        
        ivalue = await load_uvarint(self.iobj)
        fvalue = bytearray(ivalue)
        await self.iobj.areadinto(fvalue)

        if elem is None:
            return fvalue  # array by default

        elif isinstance(elem, x.BlobType):
            setattr(elem, elem_type.DATA_ATTR, fvalue)
            return elem

        else:
            elem.extend(fvalue)

        return elem
507270
def load(fname, kind="auto", *args, **kwargs):
    
    if kind == "auto":
        if fname.endswith(".bin"):
            kind = "bin"
        elif fname.endswith(".txt"):
            kind = "txt"
        else:
            raise Exception("Could not identify kind")
    if kind == "bin":
        return word2vec.WordVectors.from_binary(fname, *args, **kwargs)
    elif kind == "txt":
        return word2vec.WordVectors.from_text(fname, *args, **kwargs)
    elif kind == "mmap":
        return word2vec.WordVectors.from_mmap(fname, *args, **kwargs)
    else:
        raise Exception("Unknown kind")
1146115
function loadModels(fpath, modelFiles) {
    try {
      fpath = path.normalize(fpath);
      if (!fs.existsSync(fpath)) throw 1;
    } catch (e) {
      return false;
    }
    if (path.extname(fpath) === '.js') {
      // we have a file.
      let itemName = path.basename(fpath);
      itemName = itemName.substr(0, itemName.lastIndexOf('.'));
      let itemCode = decamelize(itemName);
      let item = {
        fullPath: fpath,
        code: itemCode,
        name: itemName,
        path: path.basename(fpath)
      };
      modelFiles.push(item);
      return true;
    }
    const items = thorin.util.readDirectory(fpath, {
      ext: 'js',
      relative: true
    });
    if (items.length === 0) {
      return true;
    }
    for (let i = 0; i < items.length; i++) {
      let itemPath = items[i];
      let item = {
        fullPath: path.normalize(fpath + '/' + itemPath)
      };
      itemPath = itemPath.substr(0, itemPath.lastIndexOf('.'));
      let itemName = decamelize(itemPath, NAME_SEPARATOR);
      itemName = itemName.split(path.sep).join(NAME_SEPARATOR);
      item.name = itemName;
      item.code = camelcase(itemName);
      item.path = itemPath.split(path.sep).join('/');
      modelFiles.push(item);
    }
    return true;
  }
159141
def load_from_file_object(cls, fd, format=None):
        
        format = 'pickle' if format is None else format
        load = getattr(cls, "load_%s" % format, None)
        if load is None:
            raise ValueError("Unknown format '%s'." % format)
        return load(fd)
398224
def load(f, dict_=dict):
    
    if not f.read:
        raise ValueError('The first parameter needs to be a file object, ',
                         '%r is passed' % type(f))
    return loads(f.read(), dict_)
1003263
def export_model(model, model_type, export_dir, model_column_fn):
  
  wide_columns, deep_columns = model_column_fn()
  if model_type == 'wide':
    columns = wide_columns
  elif model_type == 'deep':
    columns = deep_columns
  else:
    columns = wide_columns + deep_columns
  feature_spec = tf.feature_column.make_parse_example_spec(columns)
  example_input_fn = (
      tf.estimator.export.build_parsing_serving_input_receiver_fn(feature_spec))
  model.export_savedmodel(export_dir, example_input_fn,
                          strip_default_attrs=True)
143397
def load_fn_matches_ext(file_path, file_type):
    
    correct_ext = False
    curr_ext = os.path.splitext(file_path)[1]
    exts = [curr_ext, file_type]
    try:
        # special case: if file type is excel, both extensions are valid.
        if ".xlsx" in exts and ".xls" in exts:
            correct_ext = True
        elif curr_ext == file_type:
            correct_ext = True
        else:
            print("Use '{}' to load this file: {}".format(FILE_TYPE_MAP[curr_ext]["load_fn"],
                                                          os.path.basename(file_path)))
    except Exception as e:
        logger_misc.debug("load_fn_matches_ext: {}".format(e))

    return correct_ext
849796
def load_model_data(self, path, model):
        
        if os.path.isdir(path):
            # try find a model data collection
            if os.path.isfile(os.path.join(path, '_all.yml')):
                self.load_model_data_collection(path, model)
            self.load_model_data_from_files(path, model)
            self.session.commit()
1363201
def internal_model_from_file(
            self, file_name, encoding='utf-8', debug=None,
            pre_ref_resolution_callback=None, is_main_model=True):
        
        model = None
        callback = pre_ref_resolution_callback

        if hasattr(self, "_tx_model_repository"):
            # metamodel has a global repo
            if not callback:
                def _pre_ref_resolution_callback(other_model):
                    from textx.scoping import GlobalModelRepository
                    filename = other_model._tx_filename
                    assert filename
                    # print("METAMODEL PRE-CALLBACK{}".format(filename))
                    other_model._tx_model_repository = GlobalModelRepository(
                        self._tx_model_repository.all_models)
                    self._tx_model_repository.all_models\
                        .filename_to_model[filename] = other_model

                callback = _pre_ref_resolution_callback
            if self._tx_model_repository.all_models.has_model(file_name):
                model = self._tx_model_repository.all_models\
                    .filename_to_model[file_name]

        if not model:
            # model not present (from global repo) -> load it
            model = self._parser_blueprint.clone().get_model_from_file(
                file_name, encoding, debug=debug,
                pre_ref_resolution_callback=callback,
                is_main_model=is_main_model)

        for p in self._model_processors:
            p(model, self)
        return model
564902
def _load(self, layer=None):
        
        # open model file for reading and convert JSON object to dictionary
        # read and load JSON parameter map file as "parameters"
        with open(self.param_file, 'r') as param_file:
            file_params = json.load(param_file)
            for layer, params in file_params.iteritems():
                # update parameters from file
                self.parameters[layer] = ModelParameter(**params)
        # if layer argument spec'd then only update/load spec'd layer
        if not layer or not self.model:
            # update/load model if layer not spec'd or if no model exists yet
            # TODO: separate model and parameters according to comments in #78
            self.model = copy.deepcopy(self.parameters)
        else:
            # convert non-sequence to tuple
            layers = _listify(layer)
            # update/load layers
            for layer in layers:
                self.model[layer] = copy.deepcopy(self.parameters[layer])
905995
def load_model(model_file):
    
    # Extract tar
    with tarfile.open(model_file) as tar:
        tarfolder = tempfile.mkdtemp()
        tar.extractall(path=tarfolder)

    from . import features
    from . import preprocessing

    # Get the preprocessing
    with open(os.path.join(tarfolder, "preprocessing.yml"), 'r') as ymlfile:
        preprocessing_description = yaml.load(ymlfile)
    preprocessing_queue = preprocessing.get_preprocessing_queue(
        preprocessing_description['queue'])

    # Get the features
    with open(os.path.join(tarfolder, "features.yml"), 'r') as ymlfile:
        feature_description = yaml.load(ymlfile)
    feature_str_list = feature_description['features']
    feature_list = features.get_features(feature_str_list)

    # Get the model
    import nntoolkit.utils
    model = nntoolkit.utils.get_model(model_file)

    output_semantics_file = os.path.join(tarfolder, 'output_semantics.csv')
    output_semantics = nntoolkit.utils.get_outputs(output_semantics_file)

    # Cleanup
    shutil.rmtree(tarfolder)

    return (preprocessing_queue, feature_list, model, output_semantics)
247668
def metamodel_from_file(file_name, **kwargs):
    
    with codecs.open(file_name, 'r', 'utf-8') as f:
        lang_desc = f.read()

    metamodel = metamodel_from_str(lang_desc=lang_desc,
                                   file_name=file_name,
                                   **kwargs)

    return metamodel
335730
def load(cls, path_to_file):
        
        import mimetypes
        mimetypes.init()
        mime = mimetypes.guess_type('file://%s' % path_to_file)[0]
        img_type = ImageTypeEnum.lookup_by_mime_type(mime)
        with open(path_to_file, 'rb') as f:
            data = f.read()
        return Image(data, image_type=img_type)