MC-CNN 双目测距代码复现

博主在复现下面的代码时,遇到了一系列的问题,在Google在徘徊了好久才解决,先大概列出几个问题以及解决方法。

https://github.com/jzbontar/mc-cnn


问题一:

运行下面代码时出错:

./main.lua kitti fast -a predict -net_fname net/net_kitti_fast_-a_train_all.t7 -left samples/input/kittiL.png -right samples/input/kittiR.png -disp_max 70

kitti fast -a predict -net_fname net/net_kitti_fast_-a_train_all.t7 -left samples/input/kittiL.png -right samples/input/kittiR.png -disp_max 70
Found Environment variable CUDNN_PATH = /usr/local/cuda/lib64/libcudnn.so.5luajit: /home/june/torch/install/share/lua/5.1/torch/File.lua:259: read error: read 0 blocks instead of 1 at /home/june/torch/pkg/torch/lib/TH/THDiskFile.c:352
stack traceback:
[C]: in function 'readInt'
/home/june/torch/install/share/lua/5.1/torch/File.lua:259: in function 'readObject'
/home/june/torch/install/share/lua/5.1/torch/File.lua:409: in function 'load'
./main.lua:898: in main chunk
[C]: at 0x00405d50

是因为现在net与运行的不符,名字与代码里面的不对应,仔细分别或重新下载后即可解决。


问题二:

运行下面代码时出错:

./main.lua kitti slow -a train_tr
luajit: ./main.lua:378: inconsistent tensor size, expected tensor [389 x 1 x 350 x 1242] and src [] to have the same number of elements, but got 169098300 and 0 elements respectively at /home/rohan140290/torch/pkg/torch/lib/TH/generic/THTensorCopy.c:86
stack traceback:
[C]: in function 'reshape'
./main.lua:378: in function 'fromfile'
./main.lua:428: in main chunk
[C]: at 0x00405d50

问题是在main.lua里面,只要改一些代码即可:(在main.lua的378行)

if type == 'float32' then
--x = torch.FloatTensor(torch.FloatStorage(fname))

  s=1
  for i = 1,#dim do	 
 s = s * dim[i]
  end

  x = torch.FloatTensor(torch.FloatStorage(s))
  torch.DiskFile(fname,'r'):binary():readFloat(x:storage())

elseif type == 'int32' then
print('inside --------------------- 1 ')
--x = torch.IntTensor(torch.IntStorage(fname))

  s=1
  for i = 1,#dim do	 
 s = s * dim[i]
  end

  x = torch.IntTensor(torch.IntStorage(s))
  torch.DiskFile(fname,'r'):binary():readInt(x:storage())

elseif type == 'int64' then
print('inside --------------------- 3 ')
--x = torch.LongTensor(torch.LongStorage(fname))

  s=1
  for i = 1,#dim do	 
 s = s * dim[i]
  end

  x = torch.LongTensor(torch.LongStorage(s))
  torch.DiskFile(fname,'r'):binary():readLong(x:storage())

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

KevinJune

希望我的内容对你们有所帮助

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值