如何在torch7中进行多任务学习?
2017-12-12 12:16:27
收藏:0
阅读:82
评论:1
这里可以做简单的多任务网络。 但我想要像这个一样的东西 输入图像描述。 现在我按照以下方式构建模型:
model = nn.Sequential()
model:add(nn.Linear(3,5))
prl1 = nn.ConcatTable()
prl1:add(nn.Linear(5,1))
prl2 = nn.ConcatTable()
prl2:add(nn.Linear(5,1))
prl2:add(nn.Linear(5,1))
prl1:add(prl2)
model:add(prl1)
我的输出是:
input = torch.rand(5,3)
output = model:forward(input)
output
{
1 : DoubleTensor - size: 5x1
2 :
{
1 : DoubleTensor - size: 5x1
2 : DoubleTensor - size: 5x1
}
}
我应该如何构建我的标准?
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

我似乎通过两个步骤找到了解决方法:
1.在上述网络中使用nn.Concat而非nn.ConcatTable,这会使输出变成一个简单的NxM张量,例如在使用nn.Concat而非nn.ConcatTable的情况下,一个5x3张量将进入上述网络。
2.在获得NxM张量之后,我使用nn.ConcatTable、nn.Concat和nn.Select的组合来使输出成为包含每个结果张量的简单表格。
以下是第二步的一个简单示例:
model = nn.Sequential() model:add(nn.Linear(3,5)) prl = nn.ConcatTable() spl1 = nn.Concat(2) seq1 = nn.Sequential() seq1:add(nn.Select(2, 1)) seq1:add(nn.Reshape(1)) seq2 = nn.Sequential() seq2:add(nn.Select(2, 2)) seq2:add(nn.Reshape(1)) seq3 = nn.Sequential() seq3:add(nn.Select(2, 3)) seq3:add(nn.Reshape(1)) spl1:add(seq1) spl1:add(seq2) spl1:add(seq3) prl:add(spl1) spl2 = nn.Concat(2) seq4 = nn.Sequential() seq4:add(nn.Select(2, 4)) seq4:add(nn.Reshape(1)) seq5 = nn.Sequential() seq5:add(nn.Select(2, 5)) seq5:add(nn.Reshape(1)) spl2:add(seq4) spl2:add(seq5) prl:add(spl2) model:add(prl) input = torch.rand(5,3) output = model:forward(input)输出将是:
th> output { 1 : DoubleTensor - size: 5x3 2 : DoubleTensor - size: 5x2 }