You need to use .unsqueeze_(0) in your example, since the batch dimension is missing for inputconv.
nn.Conv2d expects an input of the shape [batch_size, channels, height, width].
.unsqueeze(0) adds an additional dimension at position 0, i.e. inputconv will have shape [1, 3, 4, 4].
You can create a custom filter kernel and apply it using the functional API.
The shape of the filter kernel should be [number_of_filters, input_channels, height, width].
Here is a small example:
conv_filter = torch.randn(1, 3, 5, 5)
x = torch.randn(1, 3, 24, 24)
output = F.conv2d(x, conv_filter, padding=2)