本文整理汇总了Python中solver.Solver.run方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.run方法的具体用法?Python Solver.run怎么用?Python Solver.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solver.Solver
的用法示例。
在下文中一共展示了Solver.run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Solver
# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import run [as 别名]
if args.nit:
from solver import Solver
# There should be no need to tune the solver parameters
s = Solver(prototxt, output_dir+'final.caffemodel', output_dir+'snap.caffemodel', solver=args.solver, base_lr=args.lr, weight_decay=1e-6, log_file=output_dir+'log.txt', clip_gradients=10, lr_policy="step", gamma=0.5, stepsize=10000)
s.solver.net.copy_from(args.caffemodel)
if args.random_from is not None:
sr = False
for l,n in zip(s.solver.net.layers, s.solver.net._layer_names):
if not sr:
sr = n == args.random_from
if sr and len(l.blobs)>0:
l.blobs[0].data[...] = np.random.normal(0, 0.01, l.blobs[0].shape)
if len(l.blobs)>1:
l.blobs[1].data[...] = 0.1
s.run(args.nit)
# Evaluate the model
for N_CROP in [1, 10]:
for t in ['test', 'train']:
# Specify the eval net
ns = NetSpec()
ns.data, ns.cls = dataLayer(args.voc_dir, output_dir, batch_size=1, transform_param=dict(crop_size=model.input_dim[-1], min_scale=args.min_scale, max_scale=args.max_scale, mean_value=mean_value, mirror=True, scale=args.scale), image_set=t, resize=args.resize)
ns.fc8 = L.InnerProduct( model(data=ns.data, clip=args.clip), num_output=20, name='fc8_cls')
# Create the eval net
from util import sglob
net = caffe.get_net_from_string(str(ns.to_proto()), caffe.TEST)
files = sglob(output_dir+'*.caffemodel')
if len(files)>0: