All Questions
59 questions
-1
votes
0
answers
29
views
Why does introducing dimension interactions via dot product reduce model performance?
I'm training a deep learning model where my original architecture involves an element-wise product between vectors. Specifically, the computation is straightforward:
# Original computation (element-...
0
votes
0
answers
44
views
Mismatch of values after assigning values to a tensor by index
I am writing a PyTorch training code which constructs a class of algorithm. There is a step that needs to assign some values to an internal tensor. However, even if the code is only two lines, there ...
1
vote
0
answers
26
views
Runtime error pred tensor size is 64 which is different to y_train tensor size , the tensor dim error
I'm trying to use the Hippo model to predict the forex price (the dataset have datetime column and open price column). Here's the GitHub link to the full codes GitHub Repo
The original hippo model can ...
0
votes
1
answer
159
views
How do I do masked fill in mlx?
I want to implement masked_fill in mlx but it doesn't play nice with float('-inf')
https://pytorch.org/docs/stable/generated/torch.Tensor.masked_fill.html
I'm trying to use mlx.core.where for this
...
1
vote
3
answers
714
views
How to define PyTorch tensor that is only partially trainable
I am trying to build a custom model to train in PyTorch, and long story short I need to build a tensor with all the elements set to zero except for a rectangular sub-diagonal block, crucially the ...
2
votes
1
answer
2k
views
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 18 but got size 17 for tensor number 1 in the list
I am new to Pytorch and using the pre-trained model for my Django App which restores broken images. I took the help from the code given in this repository.
My ML Model Class's code goes like this:
...
0
votes
0
answers
216
views
Output shape or tensor of tensorflow Dense and LayerNormalization layers
I am trying to apply some layer normalization and some dense layering to some tensors that i have, but when I try to get an output and see what the tensors might look like after this I get a strange ...
2
votes
3
answers
2k
views
How to create a 2D tensor of points with PyTorch, each dimension going from 0 to 1?
I'm trying to create a 2D tensor where each dimension ranges from 0 to 1.
For a 1D tensor, I can use:
torch.arange(0, 1, 0.2)
This gives me:
tensor([0.0, 0.2, 0.4, 0.6, 0.8])
But, I want to extend ...
1
vote
1
answer
426
views
Change specific parameters within a Pytorch Model layer according to a true false mask
Im trying to change specific values within the tensor of e.g. the bias of my convolutional layer according to a true false mask.
Mask = True/False mask
param = conv1.bias
benign = replacement tensor (...
1
vote
1
answer
490
views
expected scalar type Long but found Float
This code uses pytorch. It is a NLP machine learning model. I am facing problem with the model part.
16 labels=labels.type(torch.LongTensor)
17 print(labels.type())
---> 18 outputs=...
1
vote
1
answer
649
views
How can I calculate the gradients of my outputs in respect to certain input values of my Tensor with Pytorch?
I am trying to implement a Physics induced neural network, inspiration drawn from this article but my partial differential equations require a bit more complexity since I use multiple variables in my ...
0
votes
2
answers
1k
views
Slice 1D tensor in PyTorch with tensors of start and end indexes
I am trying to create a 2D tensor of even slices from a 1D tensor in PyTorch. Say we have a 1D data tensor and tensors of indexes as:
>>> data = torch.arange(10)
>>> data
tensor([0, ...
1
vote
1
answer
153
views
Pytorch tensor multi-dimensional selection
i have a question regarding the efficient operation of the pytorch tensor multidimensional selection.
Assuming i have a tensor a, with
# B=2, V=20000, d=64
a = torch.rand(B, V, d)
and a tensor b, ...
0
votes
0
answers
115
views
My label is being included as a feature when I create a pytorch model
I have started to create a pytorch model but for some reason my label ('Price_Night') is being included in my features tensor. This is my code
class AirbnbNightlyPriceImageDataset(Dataset):
def ...
0
votes
0
answers
67
views
PyTorch: Broadcasting a weighted sum of tensors
I am wondering whether I could broadcast the operation below without using a for loop.
X1 = torch.rand(B,d)
X2 = torch.rand(B,d)
X3 = torch.rand(B,d)
X = [X1,X2,X3]
w = torch.rand(3)
res = 0
for i in ...