Since the output dimension of 512 is hardcoded in the ResNet code 21, you will need to write your own custom ResNet class, and redefine this value.
Since there is no block expansion in ResNet18, you don’t have to worry about this particular aspect, and I simply changing the value (on lines 112 and 114) should work (it does on my machine).