当前位置: 首页>>代码示例>>Python>>正文


Python matlab.loadmat方法代码示例

本文整理汇总了Python中scipy.io.matlab.loadmat方法的典型用法代码示例。如果您正苦于以下问题:Python matlab.loadmat方法的具体用法?Python matlab.loadmat怎么用?Python matlab.loadmat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.io.matlab的用法示例。


在下文中一共展示了matlab.loadmat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from scipy.io import matlab [as 别名]
# 或者: from scipy.io.matlab import loadmat [as 别名]
def __init__(self, file_path: PathType):
        assert HAVE_MAT, self.installation_mesg
        super().__init__()

        file_path = Path(file_path) if isinstance(file_path, str) else file_path
        if not isinstance(file_path, Path):
            raise TypeError(f"Expected a str or Path file_path but got '{type(file_path).__name__}'")

        file_path = file_path.resolve()  # get absolute path to this file
        if not file_path.is_file():
            raise ValueError(f"Specified file path '{file_path}' is not a file.")

        self._kwargs = {"file_path": str(file_path.absolute())}

        try:  # load old-style (up to 7.2) .mat file
            self._data = loadmat(file_path, matlab_compatible=True)
            self._old_style_mat = True
        except NameError:  # loadmat not defined
            raise ImportError("Old-style .mat file given, but `loadmat` is not defined.")
        except NotImplementedError:  # new style .mat file
            try:
                self._data = h5py.File(file_path, "r+")
                self._old_style_mat = False
            except NameError:
                raise ImportError("Version 7.2 .mat file given, but you don't have h5py installed.") 
开发者ID:SpikeInterface,项目名称:spikeextractors,代码行数:27,代码来源:matsortingextractor.py

示例2: load

# 需要导入模块: from scipy.io import matlab [as 别名]
# 或者: from scipy.io.matlab import loadmat [as 别名]
def load(filename):
    """
        load any python object
    """
    fd = open(filename, "r")
    aux = cPickle.load(fd)
    fd.close()
    return aux

# def loadmat(filename):
#    """
#        load an array in matlab format
#    """
#    import scipy.io.matlab
#    aux = scipy.io.matlab.loadmat(filename)
#    fd.close()
#    return aux 
开发者ID:po0ya,项目名称:face-magnet,代码行数:19,代码来源:util.py

示例3: ReadDatasetFile

# 需要导入模块: from scipy.io import matlab [as 别名]
# 或者: from scipy.io.matlab import loadmat [as 别名]
def ReadDatasetFile(dataset_file_path):
  """Reads dataset file in Revisited Oxford/Paris ".mat" format.

  Args:
    dataset_file_path: Path to dataset file, in .mat format.

  Returns:
    query_list: List of query image names.
    index_list: List of index image names.
    ground_truth: List containing ground-truth information for dataset. Each
      entry is a dict corresponding to the ground-truth information for a query.
      The dict may have keys 'easy', 'hard', or 'junk', mapping to a NumPy
      array of integers; additionally, it has a key 'bbx' mapping to a NumPy
      array of floats with bounding box coordinates.
  """
  with tf.io.gfile.GFile(dataset_file_path, 'rb') as f:
    cfg = matlab.loadmat(f)

  # Parse outputs according to the specificities of the dataset file.
  query_list = [str(im_array[0]) for im_array in np.squeeze(cfg['qimlist'])]
  index_list = [str(im_array[0]) for im_array in np.squeeze(cfg['imlist'])]
  ground_truth_raw = np.squeeze(cfg['gnd'])
  ground_truth = []
  for query_ground_truth_raw in ground_truth_raw:
    query_ground_truth = {}
    for ground_truth_key in _GROUND_TRUTH_KEYS:
      if ground_truth_key in query_ground_truth_raw.dtype.names:
        adjusted_labels = query_ground_truth_raw[ground_truth_key] - 1
        query_ground_truth[ground_truth_key] = adjusted_labels.flatten()

    query_ground_truth['bbx'] = np.squeeze(query_ground_truth_raw['bbx'])
    ground_truth.append(query_ground_truth)

  return query_list, index_list, ground_truth 
开发者ID:tensorflow,项目名称:models,代码行数:36,代码来源:dataset.py


注:本文中的scipy.io.matlab.loadmat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。