Oh, sorry, I don’t want to make the impression to tell you how and how not to usw PyTorch. It was my impression that maybe you were looking for something more elaborate because the typical PyTorch transposition of that type of code can look suspiciously simple.
When I last did similar things, I tried to just write all the steps between the definition input variables later specified in of the Theano function call and the output in one regular Python function using PyTorch arithmetic. This looks a lot like Tony’s first example (except that the DoubleTensor constructor is probably not a good idea and you’d just use x there). In a way this should be very similar to what Theano does except that Python’s function declaration takes the place of Theano’s function call.
If there is code you find particularly difficult to translate, I’m sure we’ll try to help you out.
Best regards
Thomas