本文整理匯總了Python中caffe.proto.caffe_pb2.TEST屬性的典型用法代碼示例。如果您正苦於以下問題:Python caffe_pb2.TEST屬性的具體用法?Python caffe_pb2.TEST怎麽用?Python caffe_pb2.TEST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類caffe.proto.caffe_pb2
的用法示例。
在下文中一共展示了caffe_pb2.TEST屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: transform_param
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def transform_param(self,
mean_value=128,
batch_size=128,
scale=1., #.0078125,
mirror=1, crop_size=None, mean_file_size=None, phase=None):
new_transform_param = self.this.transform_param
if scale != 1.:
new_transform_param.scale = scale
new_transform_param.mean_value.extend([mean_value])
if phase is not None and phase == 'TEST':
return
new_transform_param.mirror = mirror
if crop_size is not None:
new_transform_param.crop_size = crop_size
示例2: resnet
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def resnet(n=3, num_output = 16):
"""6n+2, n=3 9 18 coresponds to 20 56 110 layers"""
net_name = "resnet-"
pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2))
name = net_name+str(6*n+2)+'-cifar10'
if n > 18:
# warm up
solver = Solver(solver_name="solver_warm.prototxt", folder=pt_folder, lr_policy=Solver.policy.fixed)
solver.p.base_lr = 0.01
solver.set_max_iter(500)
solver.write()
del solver
solver = Solver(folder=pt_folder)
solver.write()
del solver
builder = Net(name)
builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32)
builder.Data('cifar-10-batches-py/test', phase='TEST')
builder.resnet_cifar(n, num_output=num_output)
builder.write(folder=pt_folder)
示例3: resnet_orth
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def resnet_orth(n=3):
"""6n+2, n=3 9 18 coresponds to 20 56 110 layers"""
net_name = "resnet-orth-"
pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2))
name = net_name+str(6*n+2)+'-cifar10'
if n > 18:
# warm up
solver = Solver(solver_name="solver_warm.prototxt", folder=pt_folder, lr_policy=Solver.policy.fixed)
solver.p.base_lr = 0.01
solver.set_max_iter(500)
solver.write()
del solver
solver = Solver(folder=pt_folder)
solver.write()
del solver
builder = Net(name)
builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32)
builder.Data('cifar-10-batches-py/test', phase='TEST')
builder.resnet_cifar(n, orth=True)
builder.write(folder=pt_folder)
示例4: data_test_ssd
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def data_test_ssd(self):
layer = self.net.layer.add()
layer.name = "data"
layer.type = "AnnotatedData"
layer.top.append("data")
layer.top.append("label")
layer.include.add().phase = caffe_pb2.TEST
layer.transform_param.scale = 0.007843
layer.transform_param.mirror = True
layer.transform_param.mean_value.append(127.5)
layer.transform_param.mean_value.append(127.5)
layer.transform_param.mean_value.append(127.5)
layer.transform_param.resize_param.prob = 1.0
layer.transform_param.resize_param.resize_mode = caffe_pb2.ResizeParameter.WARP
layer.transform_param.resize_param.height = self.input_size
layer.transform_param.resize_param.width = self.input_size
layer.transform_param.resize_param.interp_mode.append(caffe_pb2.ResizeParameter.LINEAR)
layer.data_param.source = ""
layer.data_param.batch_size = 8
layer.data_param.backend = caffe_pb2.DataParameter.LMDB
layer.annotated_data_param.label_map_file = self.label_map
示例5: include
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def include(self, phase='TRAIN'):
if phase is not None:
includes = self.this.include.add()
if phase == 'TRAIN':
includes.phase = caffe_pb2.TRAIN
elif phase == 'TEST':
includes.phase = caffe_pb2.TEST
else:
NotImplementedError
#************************** inplace **************************
示例6: transform_param
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def transform_param(self, mean_value=128, batch_size=128, scale=.0078125, mirror=1, crop_size=None, mean_file_size=None, phase=None):
new_transform_param = self.this.transform_param
if scale != 1:
new_transform_param.scale = scale
if isinstance(mean_value, list):
new_transform_param.mean_value.extend(mean_value)
else:
new_transform_param.mean_value.extend([mean_value])
if phase is not None and phase == 'TEST':
return
new_transform_param.mirror = mirror
if crop_size is not None:
new_transform_param.crop_size = crop_size
示例7: BatchNorm
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def BatchNorm(self, name=None, inplace=True,eps=1e-5):
moving_average_fraction = 0
if not inplace:
bottom = self.this.name
# train
bn_name = self.suffix('bn', name)
self.setup(bn_name, 'BatchNorm', inplace=inplace)
# self.include()
self.param(lr_mult=0, decay_mult=0)
self.param(lr_mult=0, decay_mult=0)
self.param(lr_mult=0, decay_mult=0)
batch_norm_param = self.this.batch_norm_param
if eps != 1e-5:
batch_norm_param.eps = eps
return bn_name
# batch_norm_param.use_global_stats = False
#batch_norm_param.moving_average_fraction = moving_average_fraction
# test
# if not inplace:
# self.setup(bn_name, 'BatchNorm', inplace=inplace, bottom=[bottom])
# else:
# self.setup(bn_name, 'BatchNorm', inplace=inplace)
# self.include(phase='TEST')
# self.param(lr_mult=0, decay_mult=0)
# self.param(lr_mult=0, decay_mult=0)
# self.param(lr_mult=0, decay_mult=0)
# batch_norm_param = self.this.batch_norm_param
# batch_norm_param.use_global_stats = True
# batch_norm_param.moving_average_fraction = moving_average_fraction
示例8: plain
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def plain(n=3):
"""6n+2, n=3 9 18 coresponds to 20 56 110 layers"""
net_name = "plain"
pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2))
name = net_name+str(6*n+2)+'-cifar10'
solver = Solver(folder=pt_folder)
solver.write()
del solver
builder = Net(name)
builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32)
builder.Data('cifar-10-batches-py/test', phase='TEST')
builder.plain_cifar(n, num_output = 16)
builder.write(folder=pt_folder)
示例9: plain_orth
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def plain_orth(n=3):
"""6n+2, n=3 5 7 9 18 coresponds to 20 56 110 layers"""
net_name = "plain-orth"
pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2))
name = net_name+str(6*n+2)+'-cifar10'
solver = Solver(folder=pt_folder)
solver.write()
del solver
builder = Net(name)
builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32)
builder.Data('cifar-10-batches-py/test', phase='TEST')
builder.plain_cifar(n, orth=True)
builder.write(folder=pt_folder)
示例10: plain_orth_v1
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def plain_orth_v1(n=3):
"""6n+2, n=3 5 7 9 18 coresponds to 20 32 44 56 110 layers"""
net_name = "plain-orth-v1-"
pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2))
name = net_name+str(6*n+2)+'-cifar10'
solver = Solver(folder=pt_folder)
solver.write()
del solver
builder = Net(name)
builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32)
builder.Data('cifar-10-batches-py/test', phase='TEST')
builder.plain_cifar(n, orth=True, inplace=False, num_output = 16)
builder.write(folder=pt_folder)
示例11: acc
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def acc(n=3):
"""6n+2, n=3 9 18 coresponds to 20 56 110 layers"""
net_name = "plain"
pt_folder = osp.join(osp.abspath(osp.curdir), net_name +str(6*n+2))
name = net_name+str(6*n+2)+'-cifar10'
solver = Solver(folder=pt_folder)
solver.write()
del solver
builder = Net(name)
builder.Data('cifar-10-batches-py/train', phase='TRAIN', crop_size=32)
builder.Data('cifar-10-batches-py/test', phase='TEST')
builder.plain_cifar(n, num_output = 16, inplace=False)
builder.write(folder=pt_folder)
示例12: include
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def include(self, phase='TRAIN'):
if phase is not None:
includes = self.this.include.add()
if phase == 'TRAIN':
includes.phase = caffe_pb2.TRAIN
elif phase == 'TEST':
includes.phase = caffe_pb2.TEST
else:
NotImplementedError
#************************** inplace **************************
示例13: solver_and_prototxt
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def solver_and_prototxt(compress_layer, compress_rate, compress_block):
layers = ['2a', '2b', '2c', '3a', '3b', '3c', '3d',
'4a', '4b', '4c', '4d', '4e', '4f', '5a', '5b', '5c']
pt_folder = layers[compress_layer] + '_' + str(compress_block)
if not os.path.exists(pt_folder):
os.mkdir(pt_folder)
name = 'resnet-' + layers[compress_layer] + str(compress_block) +'-ImageNet'
solver = Solver(folder=pt_folder, b=compress_layer, compress_block=compress_block)
solver.write()
builder = Net(name)
builder.Data('/opt/luojh/Dataset/ImageNet/lmdb/ilsvrc12_train_lmdb', backend='LMDB', phase='TRAIN', mirror=True,
crop_size=224, batch_size=32)
builder.Data('/opt/luojh/Dataset/ImageNet/lmdb/ilsvrc12_val_lmdb', backend='LMDB', phase='TEST', mirror=False,
crop_size=224, batch_size=10)
builder.resnet_50(layers, compress_layer, compress_rate, compress_block)
builder.write(name='trainval.prototxt', folder=pt_folder)
if compress_block == 0:
compress_block = 1
compress_layer -= 1
else:
compress_block =0
builder = Net(name + '-old')
builder.setup('data', 'Data', top=['data'])
builder.resnet_50(layers, compress_layer, compress_rate, compress_block, deploy=True)
builder.write(name='deploy.prototxt', folder=pt_folder, deploy=True)
print "Finished net prototxt generation!"
示例14: ssd_predict
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def ssd_predict(self):
layer = self.net.layer.add()
layer.name = "mbox_conf_reshape"
layer.type = "Reshape"
layer.bottom.append("mbox_conf")
layer.top.append("mbox_conf_reshape")
layer.reshape_param.shape.dim.append(0)
layer.reshape_param.shape.dim.append(-1)
layer.reshape_param.shape.dim.append(self.class_num)
layer = self.net.layer.add()
layer.name = "mbox_conf_sigmoid"
layer.type = "Sigmoid"
layer.bottom.append("mbox_conf_reshape")
layer.top.append("mbox_conf_sigmoid")
layer = self.net.layer.add()
layer.name = "mbox_conf_flatten"
layer.type = "Flatten"
layer.bottom.append("mbox_conf_sigmoid")
layer.top.append("mbox_conf_flatten")
layer.flatten_param.axis = 1
layer = self.net.layer.add()
layer.name = "detection_out"
layer.type = "DetectionOutput"
layer.bottom.append("mbox_loc")
layer.bottom.append("mbox_conf_flatten")
layer.bottom.append("mbox_priorbox")
layer.top.append("detection_out")
layer.include.add().phase = caffe_pb2.TEST
layer.detection_output_param.num_classes = self.class_num
layer.detection_output_param.share_location = True
layer.detection_output_param.background_label_id = 0
layer.detection_output_param.nms_param.nms_threshold = 0.45
layer.detection_output_param.nms_param.top_k = 100
layer.detection_output_param.code_type = caffe_pb2.PriorBoxParameter.CENTER_SIZE
layer.detection_output_param.keep_top_k = 100
layer.detection_output_param.confidence_threshold = 0.35
示例15: ssd_test
# 需要導入模塊: from caffe.proto import caffe_pb2 [as 別名]
# 或者: from caffe.proto.caffe_pb2 import TEST [as 別名]
def ssd_test(self):
self.ssd_predict()
layer = self.net.layer.add()
layer.name = "detection_eval"
layer.type = "DetectionEvaluate"
layer.bottom.append("detection_out")
layer.bottom.append("label")
layer.top.append("detection_eval")
layer.include.add().phase = caffe_pb2.TEST
layer.detection_evaluate_param.num_classes = self.class_num
layer.detection_evaluate_param.background_label_id = 0
layer.detection_evaluate_param.overlap_threshold = 0.5
layer.detection_evaluate_param.evaluate_difficult_gt = False