Example of a 1D convolution

If I have a 1D data set of size 1 by D and want to apply a 1D convolution of kernel size K and the number of filters is F, how does one do it?

import torch
D = 10 # size of the data
x=torch.nn.FloatTensor(1,D)

essentially what I want to do is apply the same function (represented by the weight sharing) to each data point of x(d) (meaning it has kernel size K=1 for this example of course). So at the end of the convolution, I want to add all the values of the filters for a specific point in x to produce f(x(d)). So each convolution will have F filters and those F filters are linearly combined to produce the output of the function applied at each x(d).

Example:

You should add a batch dimension to your input x.
Besides that, you can create your desired amount of filters with kernel size 1 and sum over the time axis after the convolution.

Im not sure if thats right, I think one one need another convolution over the hidden units (not just adding stuff, that would not enforce weight sharing) because its the same function being applied at each “time” dimension.

Probably I misunderstood your drawing.
If f is another function, than yes, you have to apply another convolution/multiplication/… after summing over your filter outputs.