<s> '''<STR_LIT>''' <EOL> import caffe <EOL> from caffe import layers as L <EOL> from caffe import params as P <EOL> from nideep . proto import proto_utils as pu <EOL> class Bunch ( object ) : <EOL> def __init__ ( self , adict ) : <EOL> self . __dict__ . update ( adict ) <EOL> def edit_net_params ( path_src , target , path_dst ) : <EOL> netfile_parser = pu . Parser ( ) <EOL> x = netfile_parser . from_net_params_file ( path_src ) <EOL> print len ( x . layer ) <EOL> count = <NUM_LIT:0> <EOL> for l in x . layer : <EOL> if target . name == l . name : <EOL> print "<STR_LIT>" % l . name <EOL> print [ name for name in dir ( l ) if not name . startswith ( '<STR_LIT>' ) ] <EOL> l . data_param . batch_size = target . new_value <EOL> count += <NUM_LIT:1> <EOL> print l <EOL> return count <EOL> return <EOL> n = caffe . Net ( path_src , caffe . TEST ) <EOL> batch_size = <NUM_LIT:10> <EOL> lmdb = '<STR_LIT>' <EOL> n = caffe . NetSpec ( ) <EOL> n . data , n . label = L . Data ( batch_size = batch_size , backend = P . Data . LMDB , source = lmdb , <EOL> transform_param = dict ( scale = <NUM_LIT:1.> / <NUM_LIT:255> ) , ntop = <NUM_LIT:2> ) <EOL> n . conv1 = L . Convolution ( n . data , kernel_size = <NUM_LIT:5> , num_output = <NUM_LIT:20> , weight_filler = dict ( type = '<STR_LIT>' ) ) <EOL> n . pool1 = L . Pooling ( n . conv1 , kernel_size = <NUM_LIT:2> , stride = <NUM_LIT:2> , pool = P . Pooling . MAX ) <EOL> n . conv2 = L . Convolution ( n . pool1 , kernel_size = <NUM_LIT:5> , num_output = <NUM_LIT:50> , weight_filler = dict ( type = '<STR_LIT>' ) ) <EOL> n . pool2 = L . Pooling ( n . conv2 , kernel_size = <NUM_LIT:2> , stride = <NUM_LIT:2> , pool = P . Pooling . MAX ) <EOL> n . ip1 = L . InnerProduct ( n . pool2 , num_output = <NUM_LIT> , weight_filler = dict ( type = '<STR_LIT>' ) ) <EOL> n . relu1 = L . ReLU ( n . ip1 , in_place = True ) <EOL> n . ip2 = L . InnerProduct ( n . relu1 , num_output = <NUM_LIT:10> , weight_filler = dict ( type = '<STR_LIT>' ) ) <EOL> n . loss = L . SoftmaxWithLoss ( n . ip2 , n . label ) <EOL> t = n . tops <EOL> print t . keys ( ) <EOL> def run_edit_net_params ( ) : <EOL> path_src = '<STR_LIT>' <EOL> path_dst = '<STR_LIT>' <EOL> name = '<STR_LIT>' <EOL> key = { '<STR_LIT>' : '<STR_LIT>' } <EOL> new_value = <NUM_LIT> <EOL> target = pu . Target ( name , key , new_value ) <EOL> count = edit_net_params ( path_src , target , path_dst ) <EOL> print "<STR_LIT>" % count <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> run_edit_net_params ( ) <EOL> pass </s>
