layer { name:"fc8_flickr"# 原网络结构文件中,最后的一层就是fc8,我们在这里希望自行设计最后一层,所以我们齐了另外一个名字fc8_flickr,如果还是继续沿用fc8这个名字,就会造成finetune的时候,以前caffemodel里面的参数和权值直接填充进去。 type:"InnerProduct" bottom:"fc7" top:"fc8_flickr" # lr_mult is set to higher than for other layers, because this layer is starting from random while the others are already trained param { lr_mult:10# 基本学习率乘以10 decay_mult:1 } param { lr_mult:20 decay_mult:0 } inner_product_param { num_output:5# 这里根据实际情况,有几种数据,就改成几。因为有house、flower、animal、guitar、plane五种数据,所以改成了5。 weight_filler { type:"gaussian" std:0.01 } bias_filler { type:"constant" value:0 } } }
layer { name:"fc8_flickr" type:"InnerProduct" bottom:"fc7" top:"fc8_flickr" # lr_mult is set to higher than for other layers, because this layer is starting from random while the others are already trained param { lr_mult:10 decay_mult:1 } param { lr_mult:20 decay_mult:0 } inner_product_param { num_output:5# 这里只是修改num_output为5即可。 weight_filler { type:"gaussian" std:0.01 } bias_filler { type:"constant" value:0 } } }
net:"/home/weijian/caffe/models/finetune_test/train_val.prototxt" test_iter:30 test_interval:250 # lr for fine-tuning should be lower than when starting from scratch base_lr:0.001 lr_policy:"step" gamma:0.1 # stepsize should also be lower, as we're closer to being done stepsize:1000 每1000的迭代降低学习率:乘以gamma display:100 max_iter:150000 momentum:0.9 weight_decay:0.0005 snapshot:5000 snapshot_prefix:"/home/weijian/caffe/models/finetune_flickr_style/models/type" # uncomment the following todefaultto CPU mode solving type:"AdaDelta" solver_mode: GPU