我正在使用convnetjs来构建一个交互式教程(正如我自己学习的那样)。我有一个简单的9x9图像的'X‘和一个卷积层,其中一个滤波器作为3x3 '\'...

我预计结果会有所不同。我预计右边的圆圈结果是(-1+1+1+1+1+1+1+1+1)/9 = 0.77,而不是7.1。
在7.1版本中还发生了什么?这是由于偏见吗?我还希望整个结果在'\‘对角线上显示最高的数字,因为过滤器是与'X’的'\‘部分匹配的形状。
更新:我预计结果如下所示。偏差似乎是一个数组0.1,0.1,0.1。是什么计算产生了上面的结果(至少对于左上角的像素),而不是下面的?

<html>
<head>
<script src="http://cs.stanford.edu/people/karpathy/convnetjs/build/convnet-min.js"></script>
</head>
<body>
<script>
// Initialize an input that is 9x9 and initialized with zeroes.
let inputVol = new convnetjs.Vol(9, 9, 1, 0.0);
// Manually set the input weights from zeroes to a 'X'...
inputVol.w = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1];
// Define the layers
let layers = [];
layers.push({
type: 'input',
out_sx: 9,
out_sy: 9,
out_depth: 1
});
layers.push({
type: 'conv',
sx: 3,
pad: 0,
filters: 3,
stride: 1,
activation: 'relu'
});
let net = new convnetjs.Net();
net.makeLayers(layers);
let convLayer = net.layers[1];
let convLayerFilters = convLayer.filters;
// Set filters manually
// looks like a '\'
convLayerFilters[0].w = [1, -1, -1, -1, 1, -1, -1, -1, 1];
// looks like a 'X'
convLayerFilters[1].w = [1, -1, 1, -1, 1, -1, 1, -1, 1];
// looks like a '/'
convLayerFilters[2].w = [-1, -1, 1, -1, 1, -1, 1, -1, -1];
// Run the net
net.forward(inputVol);
// Prints '7.1' instead of '0.77'. Why???
console.log(net.layers[1].out_act.w[0]);
</script>
</body>
</html>
发布于 2017-02-10 11:41:26
是的,它的发生是因为偏置,所以它停留在定义的范围内。
偏移是可以添加到卷积结果中的每个元素的值,以添加来自相邻像素的其他影响。由于使用某些卷积可能得到负数(不能以0-255格式表示),因此偏置可防止信号漂移超出范围。您可以选择添加127或128的偏移,以允许某些负数可表示(其值中隐含+127或+128 )。
https://stackoverflow.com/questions/42148134
复制相似问题