explain this in plain english: Weight sharing There is another way to think about…
- User
explain this in plain english:
Weight sharing There is another way to think about convolutions, which introduces an important concept called weight sharing. Let’s look at the 1D case again because it is simpler to write code for. Imagine you have a neural network fΘ(·) with parameters (or weights) Θ, which takes in an input vector z with K features, z 2 RK. Now let’s say we have a larger input x with C = 1 channels and D features, where D > K. We can’t use fΘ(·) on x because the shapes D 6= K do not match. One way we could apply the network fΘ(·) to this larger dataset would be to slide the network across slices of the input and share the weights Θ for each position. Some Python pseudocode looks like this: x = torch.rand(D) Some input vector output = torch.zeros(D-K//2*2) for i in range(output.shape[0]): output[i] = f(x[i:i+K], theta) Now, if we defined our network as f = nn.Linear(K, 1), it will implement exactly a 1D convolution. This insight can teach us some important properties about convolutions and how to use them to design deep neural networks. Right now, the primary thing this teaches us is that convolutions are linear operations that work spatially. As with the nn.Linear layer from the last chapter, a convolution followed by a second convolution is equivalent to just one slightly different convolution. That means: Never repeat convolutions, because doing so is redundant. Include a nonlinear activation function after using convolutions. NOTE If we had a rectangular kernel of size (1; 3; 5), the width of the output image would be 2 · b3/2c = 2 smaller than the input. The height of the output would be 2· b5/2c = 4, removing two from each side. While rectangular kernels are possible, they are rarely used. Also notice that we have been sticking with kernels that have an odd size—nothing divisible by two. This is mostly for representational convenience because the filter is using an exact center from the input to produce each output. Like rectangular kernels, filters with even sizes are possible but are rarely used
- Assistant