caffe.Net类

caffe.Net

__init__(prototxt, phase)

@param prototxt: 字符串。指定prototxt路径
@param phase: `caffe.TRAIN`或者`caffe.TEST`
@description: 根据prototxt初始化一个网络。相当于C++的:
      shared_ptr<Net<Dtype> > net(new Net<Dtype>(param_file,
      static_cast<Phase>(phase)));
@return `Net`类对象,网络实例
@example `net = caffe.Net('test.prototxt', caffe.TEST)`

__init__(prototxt, caffemodel, phase)

@param prototxt: 字符串。指定prototxt路径
@param caffemodel: 字符串,指定caffemodel路径
@param phase: `caffe.TRAIN`或者`caffe.TEST`
@description: 根据prototxt初始化一个网络,并从caffemodel复制同名层的权值(作为网络中该层的权值)。相当于C++的:
      shared_ptr<Net<Dtype> > net(new Net<Dtype>(param_file,
          static_cast<Phase>(phase)));
      net->CopyTrainedLayersFrom(pretrained_param_file);
@return `Net`类对象,网络实例
@example `net = caffe.Net('test.prototxt', 'resnet50.caffemodel', caffe.TEST)`

_forward(start, end)

@param start: int类型
@param end: int类型
@description: 执行前向传播。调用的是C++的`Dtype Net<Dtype>::ForwardFromTo(int start, int end) `
@return: loss值
@example: 类的私有方法,所以不建议使用

_backward(start, end)

@param start: int类型
@param end: int类型
@description: 执行前向传播。调用的是C++的`void Net<Dtype>::BackwardFromTo(int start, int end) `
@return: 没有返回值。
@example: 类的私有方法,所以不建议使用

reshape()

@param: 不需要参数
@description: 网络中的每一层,都执行reshape。调用的C++的`void Net<Dtype>::Reshape() `
@return: 没有返回值类型

copy_from(caffemodel)

@param caffemodel: 字符串类型。指定(pretrained的)caffemodel路径
@description: 读取指定的caffemodel(二进制protobuf文件),从中读取和当前网络同名层的参数作为替代。调用的是C++`void Net<Dtype>::CopyTrainedLayersFrom(const string trained_filename)`
@return: 空
@example
    pretrained_caffemodel = 'abc.caffemodel'
    net = caffe.Net(prototxt, caffe.TEST)
    net.copy_from(pretrained_caffemodel)
    (来源:py-faster-rcnn)

copy_from(net)

@param net: (另一个)Net对象
@description: 从Net中读取同名网络层参数作为替代。调用的其实是`void Net<Dtype>::CopyTrainedLayersFrom(const NetParameter& param)`
@return 空
@example
    net = caffe.Net(prototxt, caffe.TEST)
    resnet = caffe.Net(prototxt_resnet, caffemodel, caffe.TEST)
    net.copy_from(resnet)

share_with(net)

@param net: Net类型。打算从net上取同名层,和当前网络共享参数。
@description: 和copy_from非常像。区别在于,被share的两个Net对象,同名层的数据是共享的!也就是内存中只有一份!改了一个,另一个也被修改!调用的是C++`void Net<Dtype>::ShareTrainedLayersWith(const Net* other) `
@return 空

_blob_loss_weights

私有属性。
返回loss函数中的每个blob的权值。按照blob_id进行索引。

_bottom_ids(i)

@param i: 层(layer)序号
@returni层的bottom们的id列表,`bottom_id_vecs_[i]`

_top_ids(i)

@param i: 层(layer)序号
@returni层的top们的id列表,`top_id_vecs_[i]`

_blobs

私有属性
返回blobs(不是很懂!)

layers

公共属性
返回layers

_blob_names

私有属性
返回blob们的名字

_layer_names

私有属性
返回layer们的名字

_inputs

私有属性。
返回`net_input_blob_indices_`,也就是网络输入们的索引们

_outputs

私有属性。
返回`net_output_blob_indices_`,也就是网络输出们的索引们

_set_input_arrays(?)

私有函数。
设定网络输入?(不懂)

save(pth)

@param pth: 字符串类型。指定保存的路径。
@description: 保存当前网络对象到文件(磁盘)。调用的是C++`void Net_Save(const Net<Dtype>& net, string filename) `
  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值