Caffe中的最小最大标准化层
Min-Max normalization Layer in Caffe
我是caffe中的新手,我试图通过最小值归一化的0到1之间的卷积输出标准化。
out = x -xmin/(xmax -xmin)
我已经检查了许多层(功率,比例,批处理归一化,MVN),但没有人在层中给我Min-Max归一化输出。有人可以帮我吗?
************
name: "normalizationCheck"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 1 dim: 1 dim: 512 dim: 512 } }
}
layer {
name: "normalize1"
type: "Power"
bottom: "data"
top: "normalize1"
power_param {
shift: 0
scale: 0.00392156862
power: 1
}
}
layer {
bottom: "normalize1"
top: "Output"
name: "conv1"
type: "Convolution"
convolution_param {
num_output: 1
kernel_size: 1
pad: 0
stride: 1
bias_term: false
weight_filler {
type: "constant"
value: 1
}
}
}
卷积层的输出不以归一化形式,我希望以层格式的最小最大归一化输出。我可以使用代码手动执行,但需要分层。谢谢
您可以按照以下准则编写自己的C 图层,您将看到如何在该页面中实现"仅向前"层。
另外,您可以在Python中实现该图层,并通过'" Python"'''lase:
在caffe中执行。首先,在Python中实现您的图层,将其存储在'/path/to/my_min_max_layer.py'
中:
import caffe
import numpy as np
class min_max_forward_layer(caffe.Layer):
def setup(self, bottom, top):
# make sure only one input and one output
assert len(bottom)==1 and len(top)==1, "min_max_layer expects a single input and a single output"
def reshape(self, bottom, top):
# reshape output to be identical to input
top[0].reshape(*bottom[0].data.shape)
def forward(self, bottom, top):
# YOUR IMPLEMENTATION HERE!!
in_ = np.array(bottom[0].data)
x_min = in_.min()
x_max = in_.max()
top[0].data[...] = (in_-x_min)/(x_max-x_min)
def backward(self, top, propagate_down, bottom):
# backward pass is not implemented!
pass
在Python中实现了层后,您只需将其添加到网络中(确保'/path/to'
在您的$PYTHONPATH
中):
layer {
name: "my_min_max_forward_layer"
type: "Python"
bottom: "name_your_input_here"
top: "name_your_output_here"
python_param {
module: "my_min_max_layer" # name of python file to be imported
layer: "min_max_forward_layer" # name of layer class
}
}
相关文章:
- CAFFE转发网络在for循环中不起作用
- 是否有一种标准化的方法通过TCP/IP网络发送JPG图像
- 使用Caffe和CUDA的C++程序
- Tensorflow C++ API 和 Caffe 兼容性问题与 Glog 相关
- Caffe LSTM 层不起作用
- caffe 可以一次接收一批具有不同分辨率的输入吗?如果是这样,怎么办?
- Caffe 或 Caffe2 可以直接从 GPU 获得输入数据吗?
- C++是否在 std::min 和 std::max 下标准化 std::optional 的行为?
- 密钥错误: "Couldn't find enum caffe.EmitConstraint.EmitType"
- Caffe在net_.reset上打印整个protext文件(new Net<float>(model_file,TEST))
- 无法使用 OpenCV 读取网络从咖啡加载数字训练的 Caffe 模型
- src/caffe/parallel.cpp:70:1:错误:“参数”未命名类型
- Caffe 源代码中层函数标头中指针运算符的含义
- 在 Caffe 中,如何修改特定卷积层的行为?
- C++"extension methods"标准化的建议在哪里?
- 创建多个 Caffe 实例 - C++
- Caffe中的交叉熵实现
- 在C 中使用Caffe;无法将Caffe ::求解参数仪发挥作用而不会出错
- 在进行前向推理时,Caffe 的 GPU 利用率不够充分,知道吗?
- Caffe中的最小最大标准化层