Hi there,
I don’t understand how the above code can work. Keras convolution weights are stored as
[Kx, Ky, C_in, C_out]

while Pytorch Conv2d weights are stored as
[C_out, C_in, Kx, Ky]

And a simple transposition does not take you from one to the other. See documentation below.
Could you please clarify if you really got the code above to work, or if you needed to implement a more complicated permutation between Keras and Pytorch tensors? Thanks!

  
      

      TensorFlow
  

  
    

tf.nn.conv2d  |  TensorFlow Core v2.6.0 4

  Computes a 2-D convolution given input and 4-D filters tensors.


  

  
    
    
  

  

https://pytorch.org/docs/stable/generated/torch.nn.Conv2d.html 3