如何在多任务设置中将多标签数据作为 HDF5 输入提供?
How to feed multi label data as HDF5 input in a multi task setup?
我有一个数据集,每个图像都有大约 101 个标签。我知道,我必须使用 HDF5 数据层将我的数据馈送到网络中。但问题是我有一个多任务设置。我的网络共享前 5 层的参数,然后分支。在 101 个标签中,我想将 100 个标签发送到一个任务,将 1 个标签发送到第二个任务。
现在,我该怎么做?我能以某种方式执行以下操作吗:
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "label1" ############# A scalar label
top : "label2" ######## A vector of size 100
include {
phase: TRAIN
}
hdf5_data_param {
source: "path/to/the/text/file/test.txt"
batch_size: 10
}
}
上面的设置中有两个顶部 blob。一个用于 100 维向量 (label2
),另一个用于剩余标签 (label1
)。
这种设置可行吗?
我还在某处读到,可以拆分多维向量,在 prototxt 文件本身中指定拆分规范。在那种情况下,我将不得不使用单个顶部 blob 作为标签(101 维),然后以某种方式拆分
100 维和 1 维(标量)两个向量中的 101 维向量。如何做到这一点?
在这种情况下,该层会喜欢:
layer {
name: "data"
type: "HDF5Data"
top: "data"
top : "label" ######## A vector of size 101
include {
phase: TRAIN
}
hdf5_data_param {
source: "path/to/the/text/file/test.txt"
batch_size: 10
}
}
## Some layer to split the label blob into two vectors of 100-d and 1-d respectively
知道这种拆分如何运作吗?
您提出的原始设置("HDF5Data"
层具有三个 top
s)在 caffe 中是可能的并且完全可以。事实上,caffe支持网络形成的图中任意方向的非循环数据流。您可以有多个 bottom
和多个损失层。没关系。
如果你坚持要有一个101维的label
输入,你可以使用"Slice"
层
拆分它
layer {
type: "Slice"
name: "slice/label"
bottom: "label" # assuming shape batch_size-101-1-1
top: "label1" # first 1D label
top: "label2" # second 100D label
slice_param {
axis: 1 # along "channels" dimension
slice_point: 1 # slice after the first element
}
}
有关"Slice"
层参数的更多信息,您可以查看caffe.proto。
我有一个数据集,每个图像都有大约 101 个标签。我知道,我必须使用 HDF5 数据层将我的数据馈送到网络中。但问题是我有一个多任务设置。我的网络共享前 5 层的参数,然后分支。在 101 个标签中,我想将 100 个标签发送到一个任务,将 1 个标签发送到第二个任务。
现在,我该怎么做?我能以某种方式执行以下操作吗:
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "label1" ############# A scalar label
top : "label2" ######## A vector of size 100
include {
phase: TRAIN
}
hdf5_data_param {
source: "path/to/the/text/file/test.txt"
batch_size: 10
}
}
上面的设置中有两个顶部 blob。一个用于 100 维向量 (label2
),另一个用于剩余标签 (label1
)。
这种设置可行吗?
我还在某处读到,可以拆分多维向量,在 prototxt 文件本身中指定拆分规范。在那种情况下,我将不得不使用单个顶部 blob 作为标签(101 维),然后以某种方式拆分
100 维和 1 维(标量)两个向量中的 101 维向量。如何做到这一点?
在这种情况下,该层会喜欢:
layer {
name: "data"
type: "HDF5Data"
top: "data"
top : "label" ######## A vector of size 101
include {
phase: TRAIN
}
hdf5_data_param {
source: "path/to/the/text/file/test.txt"
batch_size: 10
}
}
## Some layer to split the label blob into two vectors of 100-d and 1-d respectively
知道这种拆分如何运作吗?
您提出的原始设置(
"HDF5Data"
层具有三个top
s)在 caffe 中是可能的并且完全可以。事实上,caffe支持网络形成的图中任意方向的非循环数据流。您可以有多个bottom
和多个损失层。没关系。如果你坚持要有一个101维的
拆分它label
输入,你可以使用"Slice"
层layer { type: "Slice" name: "slice/label" bottom: "label" # assuming shape batch_size-101-1-1 top: "label1" # first 1D label top: "label2" # second 100D label slice_param { axis: 1 # along "channels" dimension slice_point: 1 # slice after the first element } }
有关
"Slice"
层参数的更多信息,您可以查看caffe.proto。