There seem to be a few issues in your code.
I’m not completely sure, how your custom convolution works, but usually an input to a conv layer should have the shape [batch_size, channels, height, width]. Currently your input has only two dimensions, so you might need to unsqueeze it and probably adapt the for loop in your custom conv layer to work on dim2 or dim3.
You can’t properly backprobagate, since you are detaching the computation graph by wrapping the output in a new tensor.
Just try to pass outputs and targets to your loss function.
However, in the current code you’ll get a size mismatch error.
nn.CrossentropyLoss expects and input of [batch_size, nb_classes] as the model output and [batch_size] as the target tensor containing class indices in the vanilla use case as described in the docs 3.
You can also pass multi-dimensional model outputs targets with additional dimension to this loss function, e.g. for pixel-wise classification.
Based on your current target shape, it seems that your model output should be the vanilla case: [batch_size, nb_classes].
This is usually done using a linear layer as the output layer.