Skip to content
Advertisement

Tag: pytorch

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

Reshape original X from LSTM with predictions

I have a tensor with my LSTM inputs X (in PyTorch) as well as the matching predictions Y_hat I want to add the Y_hat as a column to the original X. The problem is that LSTM a sliding window with seq_length. In case seq. length is 3 and I have 6 variables in X, and 2 variables in Y_hat, I

Imported package searches for modules in my code

Can someone explain me what is going on here and how to prevent this? I have a main.py with the following code: I outsourced some functions into a module named utils.py: When I run this I get the following output: So it seems like the torch package I imported has also a utils resource (package) and searches for a module

How do I create a model from a state dict?

I am trying to load a checkpoint pth file from the faster_rcnn_resnet101 model which is not currently in the PyTorch model zoo. This causes PyTorch to throw a KeyError saying that I the layers in the state dict does not match the model architecture of faster_rcnn_fpn_resnet50 that I’ve loaded from the model zoo. Note: I tried posting the architecture of

`torch.gather` without unbroadcasting

I have some batched input x of shape [batch, time, feature], and some batched indices i of shape [batch, new_time] which I want to gather into the time dim of x. As output of this operation I want a tensor y of shape [batch, new_time, feature] with values like this: In Tensorflow, I can accomplish this by using the batch_dims:

Advertisement