proto_file.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Sensor-Specific-Hyperspectral-Image-Feature-Learning 作者: MeiShaohui 项目源码 文件源码
def deploy_net(conf, batch_size, class_num) :
    '''
    :param conf:  the data_set_config information, defined in data_info_set.item
    :param batch_size: the batch_size of prototxt
    :param class_num: the class_num of the data_set
    :param channels: the channels of hyperspectral data, maybe it is 224,448 or 103,206
    :param kernel_size: the kernel_size of the convolution layer, often is 1/9 of the channels
    :return: deploy file handle
    '''
    n = caffe.NetSpec()
    if conf.use_CK is True:
        n.data, n.label = L.DummyData(shape= {'dim' : [batch_size, 1, conf.CK_channels, 1]}, ntop = 2)
        n.conv1 = L.Convolution(n.data, kernel_h=conf.CK_kernel_size, kernel_w=1, num_output=20,
                                weight_filler=dict(type='gaussian', std=0.05),
                                bias_filler=dict(type='constant', value=0.1))
    else:
        n.data, n.label = L.DummyData(shape= {'dim' : [batch_size, 1, conf.channels, 1]}, ntop = 2)
        n.conv1 = L.Convolution(n.data, kernel_h = conf.kernel_size, kernel_w = 1, num_output = 20,
                                weight_filler = dict(type = 'gaussian', std = 0.05),
                                bias_filler = dict(type = 'constant', value = 0.1))
    n.bn1 = L.BatchNorm(n.conv1, use_global_stats = 1, in_place = True)
    n.relu1 = L.PReLU(n.bn1, in_place = True)
    n.ip1 = L.InnerProduct(n.relu1, num_output = 100, weight_filler = dict(type = 'gaussian', std = 0.05),
                           bias_filler = dict(type = 'constant', value = 0.1))
    n.drop1 = L.Dropout(n.ip1, dropout_ratio = 0.1, in_place = True)
    n.relu2 = L.PReLU(n.drop1, in_place = True)
    n.ip2 = L.InnerProduct(n.relu2, num_output = class_num, weight_filler = dict(type = 'gaussian', std = 0.05),
                            bias_filler = dict(type = 'constant', value = 0.1))
    return n.to_proto()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号