windows下caffe的matlab接口


windows下caffe的matlab接口
资源截图
代码片段和文件信息
classdef Blob < handle
  % Wrapper class of caffe::Blob in matlab
  
  properties (Access = private)
    hBlob_self
  end
  
  methods
    function self = Blob(hBlob_blob)
      CHECK(is_valid_handle(hBlob_blob) ‘invalid Blob handle‘);
      
      % setup self handle
      self.hBlob_self = hBlob_blob;
    end
    function shape = shape(self)
      shape = caffe_(‘blob_get_shape‘ self.hBlob_self);
    end
    function reshape(self shape)
      shape = self.check_and_preprocess_shape(shape);
      caffe_(‘blob_reshape‘ self.hBlob_self shape);
    end
    function data = get_data(self)
      data = caffe_(‘blob_get_data‘ self.hBlob_self);
    end
    function set_data(self data)
      data = self.check_and_preprocess_data(data);
      caffe_(‘blob_set_data‘ self.hBlob_self data);
    end
    function diff = get_diff(self)
      diff = caffe_(‘blob_get_diff‘ self.hBlob_self);
    end
    function set_diff(self diff)
      diff = self.check_and_preprocess_data(diff);
      caffe_(‘blob_set_diff‘ self.hBlob_self diff);
    end
  end
  
  methods (Access = private)
    function shape = check_and_preprocess_shape(~ shape)
      CHECK(isempty(shape) || (isnumeric(shape) && isrow(shape)) ...
        ‘shape must be a integer row vector‘);
      shape = double(shape);
    end
    function data = check_and_preprocess_data(self data)
      CHECK(isnumeric(data) ‘data or diff must be numeric types‘);
      self.check_data_size_matches(data);
      if ~isa(data ‘single‘)
        data = single(data);
      end
    end
    function check_data_size_matches(self data)
      % check whether size of data matches shape of this blob
      % note: matlab arrays always have at least 2 dimensions. To compare
      % shape between size of data and shape of this blob extend shape of
      % this blob to have at least 2 dimensions
      self_shape_extended = self.shape;
      if isempty(self_shape_extended)
        % target blob is a scalar (0 dim)
        self_shape_extended = [1 1];
      elseif isscalar(self_shape_extended)
        % target blob is a vector (1 dim)
        self_shape_extended = [self_shape_extended 1];
      end
      % Also matlab cannot have tailing dimension 1 for ndim > 2 so you
      % cannot create 20 x 10 x 1 x 1 array in matlab as it becomes 20 x 10
      % Extend matlab arrays to have tailing dimension 1 during shape match
      data_size_extended = ...
        [size(data) ones(1 length(self_shape_extended) - ndims(data))];
      is_matched = ...
        (length(self_shape_extended) == length(data_size_extended)) ...
        && all(self_shape_extended == data_size_extended);
      CHECK(is_matched ...
        sprintf(‘%s input data/diff size: [ %s] vs target blob shape: [ %s]‘ ...
        ‘input data/diff size does not match target blob shape‘ ...
        sprintf(‘%d ‘ data_size_extended) sprintf(‘%d ‘ self_shape_extended)));
    end
  end
end

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        648  2016-02-04 00:38  matlab+caffe+test est_io.m

     文件       3971  2016-02-04 00:38  matlab+caffe+test est_net.m

     文件       1422  2016-02-04 00:38  matlab+caffe+test est_solver.m

     文件       2930  2016-02-04 00:38  matlab+caffeBlob.m

     文件       1207  2016-02-04 00:38  matlab+caffeget_net.m

     文件        298  2016-02-04 00:38  matlab+caffeget_solver.m

     文件     606799  2016-02-04 00:38  matlab+caffeimagenetilsvrc_2012_mean.mat

     文件        191  2016-02-04 00:38  matlab+caffeinit_glog.m

     文件       1742  2016-02-04 00:38  matlab+caffeio.m

     文件        841  2016-02-04 00:38  matlab+caffelayer.m

     文件       6222  2016-02-04 00:38  matlab+caffeNet.m

     文件      23411  2016-02-04 00:38  matlab+caffeprivatecaffe_.cpp

     文件        856  2016-02-20 15:26  matlab+caffeprivatecaffe_.exp

     文件       1720  2016-02-20 15:26  matlab+caffeprivatecaffe_.lib

     文件    4713984  2016-02-20 15:26  matlab+caffeprivatecaffe_.mexw64

     文件   15993856  2016-02-20 15:26  matlab+caffeprivatecaffe_.pdb

     文件         71  2016-02-04 00:38  matlab+caffeprivateCHECK.m

     文件        118  2016-02-04 00:38  matlab+caffeprivateCHECK_FILE_EXIST.m

     文件        935  2016-02-04 00:38  matlab+caffeprivateis_valid_handle.m

     文件         71  2016-02-04 00:38  matlab+caffeprivatematcaffe.def

     文件        250  2016-02-04 00:38  matlab+caffe
ead_mean.m

     文件        172  2016-02-04 00:38  matlab+caffe
eset_all.m

     文件        393  2016-02-04 00:38  matlab+caffe
un_tests.m

     文件        250  2016-02-04 00:38  matlab+caffeset_device.m

     文件         97  2016-02-04 00:38  matlab+caffeset_mode_cpu.m

     文件         97  2016-02-04 00:38  matlab+caffeset_mode_gpu.m

     文件       1787  2016-02-04 00:38  matlab+caffeSolver.m

     文件       3049  2016-02-04 00:38  matlabCMakeLists.txt

     文件       3544  2016-03-18 20:04  matlabdemoclassification_demo.m

     文件       3255  2016-02-04 00:38  matlabdemogetCifar10Feature.m

............此处省略15个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)