Torch7入门续集(四)----表层构建灵活的网络
发布时间
阅读量:
阅读量
总说
先补充一些具有实用价值的内容。
replace(function)
这一操作方式可以理解为将特定的function应用至网络结构中的每一层。例如,在模型中将原本使用的nn.Dropout模块替换为nn.Identity(),此时无论传入的参数module被定义为任何变量名称,其均代表网络中的某一层结构。
model:replace(function(module)
if torch.typename(module) == 'nn.Dropout' then
return nn.Identity()
else
return module
end
end)
apply(function)
这种方式与前述方法相似,同样针对每一层执行相应处理。
local function weights_init(m)
local name = torch.type(m)
if name:find('Convolution') then
m.weight:normal(0.0,
全部评论 (0)
还没有任何评论哟~
