Skip to content

Tag: pytorch

Why tensor size was not changed?

I made the toy CNN model. Then, I had checked model.summary via this code And I was able to get the following results: I want to reduce model size cuz i wanna increase the batch size. So, I had changed torch.float32 -> torch.float16 via NVIDIA/apex As a result, torch.dtype was changed torch.float16 from to…

How to avoid two variables refering to the same data? #Pytorch

During initializing, I tried to reduce the repeats in my code, so instead of: I wrote: However, I find that the second method is wrong. If I assign the data to variables h,c, any change on h would also be applied to c results of the test above: Is there a more elegent way to initialize two indenpendent variab…

Receiving Infinity Infinity in LineString

I am try get linestring so I can measure the distance and time. Here in this linestring I am getting nan distance and time. Also, pleased to hear any of your suggestion on my code or logic. Thanks data: Code: Output: Answer Probably, previous pyproj EPSG was switching the opposite interpretation. So I change …

How to test a trained model saved in .pth.tar files?

I am working with CORnet-Z and I am building a separate test file. The model seems to be saved as .pth.tar files What would be the best approach to load this model and run evaluation and testing? Answer To test a model you need to load the state dictionary of your trained model and optimizer (if applicable). …

How to efficiently draw a plot of a torch.nn model?

I’m exploring neural networks, and I want to model some pictures with neural network. Picture is a function that maps pixel coordinates to color, so I make my network also with 2 input variables (x, y) and 1 (shade) to 3 (R, G, B) output coordinates. For example, like this: Now, I plot it like this: But…

Whats the purpose of torch.positive?

From the documentation: torch.positive(input) → Tensor Returns input. Throws a runtime error if input is a bool tensor. It just returns the input and throws error if its a bool tensor, but that’s not an efficient nor readable way of checking if a tensor is bool. Answer It seems like pytorch added pytorc…