Enet caffe训练错误

左手的ㄟ右手 2022-05-23 06:35 332阅读 0赞

转自: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. import caffe
  5. caffe.set_device(0)
  6. caffe.set_mode_gpu()
  7. solver = caffe.SGDSolver(‘/home/xxx/data/solver.prototxt’)
  8. 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. import caffe
  5. caffe.set_device(0)
  6. caffe.set_mode_gpu()
  7. solver = caffe.SGDSolver(‘/home/xxx/data/solver.prototxt’)
  8. solver.net.copy_from(‘models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel’)

  9. # We run the solver for niter times, and record the training loss.

  10. for it in range(niter):
  11. 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 条评论,332人围观)

还没有评论,来说两句吧...

相关阅读