Skip to content

Tag: pytorch

PyTorch: Dataloader for time series task

I have a Pandas dataframe with n rows and k columns loaded into memory. I would like to get batches for a forecasting task where the first training example of a batch should have shape (q, k) with q referring to the number of rows from the original dataframe (e.g. 0:128). The next example should be (128:256, …

ModuleNotFoundError: No module named ‘tools.nnwrap’

I tried to install torch using: Installation started, but after a few seconds I got the error: OS: Windows Answer Anyone who is looking for the solution refer below: It seems command to install torch not is working as expected, instead, you can try to install PyTorch using below command. It’s working an…

Assigning values to torch tensors

I’m trying to assign some values to a torch tensor. In the sample code below, I initialized a tensor U and try to assign a tensor b to its last 2 dimensions. In reality, this is a loop over i and j that solves some relation for a number of training data (here 10) and assigns it to its corresponding

Pytorch – Inferring linear layer in_features

I am building a toy model to take in some images and give me a classification. My model looks like: conv2d -> pool -> conv2d -> linear -> linear. My issue is that when we create the model, we have to calculate the size of the first linear layer in_features based on the size of the input image. If …

Finding non-intersection of two pytorch tensors

Thanks everyone in advance for your help! What I’m trying to do in PyTorch is something like numpy’s setdiff1d. For example given the below two tensors: The expected output should be (sorted or unsorted): Ideally the operations are done on GPU and no back and forth between GPU and CPU. Much apprec…

How does pytorch’s nn.Module register submodule?

When I read the source code(python) of torch.nn.Module , I found the attribute self._modules has been used in many functions like self.modules(), self.children(), etc. However, I didn’t find any functions updating it. So, where will the self._modules be updated? Furthermore, how does pytorch’s nn.…

No module named “Torch”

I successfully installed pytorch via conda: I also successfully installed pytorch via pip: But, it only works in a jupyter notebook. Whenever I try to execute a script from the console, I get the error message: No module named “torch” Answer Try to install PyTorch using pip: First create a Conda e…