1. 程式人生 > >caffe Python API 之Solver定義

caffe Python API 之Solver定義

from caffe.proto import caffe_pb2

s = caffe_pb2.SolverParameter()

path='/home/xxx/data/'
solver_file=path+'solver.prototxt'     #solver檔案儲存位置

s.train_net = path+'train.prototxt'     # 訓練配置檔案
s.test_net.append(path+'val.prototxt')  # 測試配置檔案
s.test_interval = 782                   # 測試間隔
s.test_iter.append(313)                 #
測試迭代次數
s.iter_size=4                #累計迭代次數
s.max_iter = 78200 # 最大迭代次數 s.base_lr = 0.001 # 基礎學習率 s.momentum = 0.9 # momentum係數 s.weight_decay = 5e-4 # 權值衰減係數 s.lr_policy = 'step' # 學習率衰減方法 s.stepsize=26067 #
此值僅對step方法有效 s.gamma = 0.1 # 學習率衰減指數 s.display = 782 # 螢幕日誌顯示間隔 s.snapshot = 7820 s.snapshot_prefix = 'shapshot' s.type = “SGD” # 優化演算法 s.solver_mode = caffe_pb2.SolverParameter.GPU with open(solver_file, 'w') as f: f.write(str(s))