Caffe 将 AlexNet 的预训练权重复制到具有两个 AlexNet 的自定义网络
Caffe Copy PreTrained Weights of AlexNet to custom network that has Two AlexNets
我正在尝试构建一个包含两个图像输入的网络。每张图像将同时通过一个网络,后期融合将合并并给出一个输出。我用下面的图表来展示我需要的东西(ps:抱歉我的英语不太好)
我的网络在 caffe prototxt 模型定义文件中定义,其中包含两次定义到 Pool 5 的确切 AlexNet。对于第一个网络,层与 AlexNet 中的名称相同,而对于第二个网络,我添加了一个 "_1" 每个图层名称的后缀。
我的问题是如何复制预留重量?
例如:我的每个网络的卷积层1如下。请注意,对于 conv1
,可以轻松复制预训练权重,因为层名称与预训练模型中的层名称相同。但是 conv1_1
的相同是不同的,所以恐怕我无法复制预训练的权重?或者即使图层名称不同也有办法做到这一点吗?
layer {
name: "conv1"
type: "Convolution"
bottom: "data1"
top: "conv1"
param {
lr_mult: 0
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 96
kernel_size: 11
stride: 4
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "conv1_1"
type: "Convolution"
bottom: "data2"
top: "conv1_1"
param {
lr_mult: 0
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 96
kernel_size: 11
stride: 4
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
我假设您正在尝试在初始化后微调整个网络,否则您可以简单地使用从 AlexNet 中提取的特征并在 FC 层开始训练。对于微调,您需要复制第一个网络(同名网络)上的权重,并让第二个网络与第一个网络共享权重。查看 Evan Shelmar 的 this thread. Or rather this 回复。
我做了类似的事情,在这里你可以看到 Siamese Network 和 Identical AlexNet。 Identical AlexNet for Siamese Network. Here is prototxt file
我正在尝试构建一个包含两个图像输入的网络。每张图像将同时通过一个网络,后期融合将合并并给出一个输出。我用下面的图表来展示我需要的东西(ps:抱歉我的英语不太好)
我的网络在 caffe prototxt 模型定义文件中定义,其中包含两次定义到 Pool 5 的确切 AlexNet。对于第一个网络,层与 AlexNet 中的名称相同,而对于第二个网络,我添加了一个 "_1" 每个图层名称的后缀。 我的问题是如何复制预留重量?
例如:我的每个网络的卷积层1如下。请注意,对于 conv1
,可以轻松复制预训练权重,因为层名称与预训练模型中的层名称相同。但是 conv1_1
的相同是不同的,所以恐怕我无法复制预训练的权重?或者即使图层名称不同也有办法做到这一点吗?
layer {
name: "conv1"
type: "Convolution"
bottom: "data1"
top: "conv1"
param {
lr_mult: 0
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 96
kernel_size: 11
stride: 4
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "conv1_1"
type: "Convolution"
bottom: "data2"
top: "conv1_1"
param {
lr_mult: 0
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 96
kernel_size: 11
stride: 4
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
我假设您正在尝试在初始化后微调整个网络,否则您可以简单地使用从 AlexNet 中提取的特征并在 FC 层开始训练。对于微调,您需要复制第一个网络(同名网络)上的权重,并让第二个网络与第一个网络共享权重。查看 Evan Shelmar 的 this thread. Or rather this 回复。
我做了类似的事情,在这里你可以看到 Siamese Network 和 Identical AlexNet。 Identical AlexNet for Siamese Network. Here is prototxt file