What i would do if it was me, would be to go throug hthe network, and print out the various intermediate values. make sure to seed both the tensorflow and torch weights etc with identical values (eg using manual_seed() and similar, or just use some deterministic way to initialize them, or initialize them from a file, or something, that is repeatable, and identical across both tensorflow and torch. and then just compare the intermediates between tensorflow and torch. I think this will be more reliable than trying to compare the code line by line, not being clear which lines to pay most attention to.