Skip to content
Advertisement

Tag: pytorch

The shuffling order of DataLoader in pytorch

I am really confused about the shuffle order of DataLoader in pytorch. Supposed I have a dataset: In scenario I, the code is: the shuffling result is 0,4,2,3,1. In scenario II, the code is: the shuffling result is 1,3,4,0,2. In scenario III, the code is: the shuffling result is 4,1,3,0,2. Can someone explain what is going on here? Answer Based

Select pytorch tensor elements by list of indices

I guess I have a pretty simple problem. Let’s take the following tensor of length 6 Now I would like to to access only the elements at specific indices, lets say at [0, 3, 4]. So I would like to return I found torch.index_select which worked great for a tensor of two dimensions, e.g. dimension (2, 4), but not for

Installed Pytorch 1.12 in the environment but detects version 1.10.0+cpu

Recently, I have installed pytorch 1.12.1 in the conda environment. After installation, I checked the version of pytorch using print(torch.__version__), it returns 1.10.0+cpu. I also checked the available packages in the environment. It shows pytorch version 1.12.1 as shown in figure below. I am unable to understand why it is detecting version 1.10.0+cpu. I even reinstalled Anaconda python in Windows,

In PyTorch, how do I update a neural network via the average gradient from a list of losses?

I have a toy reinforcement learning project based on the REINFORCE algorithm (here’s PyTorch’s implementation) that I would like to add batch updates to. In RL, the “target” can only be created after a “prediction” has been made, so standard batching techniques do not apply. As such, I accrue losses for each episode and append them to a list l_losses

What is the most efficient way to make a method that is able to process single and multi dimensional arrays in python?

I was using pytorch and realized that for a linear layer you could pass not only 1d tensors but multidmensional tensors as long as the last dimensions matched. Multi dimensional inputs in pytorch Linear method? I tried looping over each item, but is that what pytorch does? I’m having trouble thinking how you would program looping with more dimensions, maybe

How to replace PyTorch model layer’s tensor with another layer of same shape in Huggingface model?

Given a Huggingface model, e.g. I can access a layer’s tensor as such: [out]: Given the another tensor of the same shape that I’ve pre-defined from somewhere else, in this case, for illustration, I’m creating a random tensor but this can be any tensor that is pre-defined. Note: I’m not trying to replace a layer with a random tensor but

Advertisement