-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdata_addnoise.lua
37 lines (32 loc) · 986 Bytes
/
data_addnoise.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'torch'
require 'nn'
require 'optim'
require 'paths'
assert(pcall(function () mat = require('fb.mattorch') end) or pcall(function() mat = require('matio') end), 'no mat IO interface available')
opt = {
data_dir='/data/jjliu/models',
data_name='proj_inputs_voxel/test_chair4854',
droprate = 0.3,
gpu=1,
}
for k,v in pairs(opt) do opt[k] = tonumber(os.getenv(k)) or os.getenv(k) or opt[k] end
if opt.gpu > 0 then
require 'cunn'
require 'cudnn'
require 'cutorch'
cutorch.setDevice(opt.gpu)
end
print(paths.concat(opt.data_dir, opt.data_name .. '.mat'))
local obj = mat.load(paths.concat(opt.data_dir, opt.data_name .. '.mat'), 'off_volume')
local dropNN = nn.Dropout()
if opt.gpu > 0 then
obj = obj:cuda()
dropNN = dropNN:cuda()
dropNN = cudnn.convert(dropNN, cudnn)
end
obj = dropNN:forward(obj)
if opt.gpu > 0 then
obj = obj:double()
end
out_path = paths.concat(opt.data_dir, opt.data_name .. '_drop.mat')
mat.save(out_path, {['off_volume'] = obj})