Enet caffe训练错误

转自:https://blog.csdn.net/hong__fang/article/details/78530390 

根据ENet说明https://github.com/TimoSaemann/ENet/tree/master/Tutorial ,进行训练遇到以下问题

1 No module named spatial_dropout

   新增加的Python层如果用caffe-root/caffe train -solver  solver.prototxt方式可能会出现找不到新添加的Python层,此时需要将新添加的Python层文件的路径添加到环境变量中,通过终端python后输入import  **.py看是否添加,然后通过Python接口来训练,如下:

   ENet通过python接口定义了新层spatial_dropout,根据说明直接在终端启动训练,出现“No module named spatial_dropout”,原因是caffe,python层所在文件夹路径,没有添加到系统PYTHONPATH,一个解决方法是:用Python接口来启动训练:

[python]  view plain  copy
  1. import sys    
  2. caffe_root = 'home/f/caffe/'    
  3. sys.path.insert(0,caffe_root+'python')    
  4.   
  5. import caffe  
  6. caffe.set_device(0)  
  7. caffe.set_mode_gpu()  
  8. solver = caffe.SGDSolver('/home/xxx/data/solver.prototxt')  
  9. solver.solve()  

若采用微调的方式进行训练则如下,参考https://blog.csdn.net/lilai619/article/details/54343395 

[python]  view plain  copy
  1. import sys    
  2. caffe_root = 'home/f/caffe/'    
  3. sys.path.insert(0,caffe_root+'python')    
  4.   
  5. import caffe  
  6. caffe.set_device(0)  
  7. caffe.set_mode_gpu()  
  8. solver = caffe.SGDSolver('/home/xxx/data/solver.prototxt')  
  9. solver.net.copy_from('models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel') 
  10. # We run the solver for niter times, and record the training loss. 
  11. for it in range(niter):    
  12.     solver.step(1)  # SGD by Caffe 


2 drop1_0_3 新建时,  img_height == height 验证失败

   data层的new_height new_weight不能删掉,根据输入图像设定大小即可。

[python]  view plain  copy
  1. layer {  
  2.   name: "data"  
  3.   type: "DenseImageData"  
  4.   top: "data"  
  5.   top: "label"  
  6.   dense_image_data_param {  
  7.     source: "ENet/dataset/train_fine_2columns.txt"  
  8.     batch_size: 4  
  9.     shuffle: true  
  10.     new_height: 512  
  11.     new_width: 1024  
  12.     label_divide_factor: 8  
  13.   }  
  14. }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值