Why does shadowor.view () not work in pytorch?

I have the following code snippet.

embedded = self.embedding(input).view(1, 1, -1)
embedded = self.drop(embedded)
print(embedded[0].size(), hidden[0].size())
concatenated_output = torch.cat((embedded[0], hidden[0]), 1)

The last line of code gives me the following error.

RuntimeError: inconsistent tensor sizes in / data / users / soumith / miniconda 2 / conda-bld / pytorch-0.1.9_1487344852722 / work / torch / lib / THC / generic / THCTensorMath.cu: 141

Notice when I print tensor figures in line No. 3, I get the following output.

torch.size([1, 300]) torch.size([1, 1, 300]) 

Why do I get the form [1, 300]for the tensor embedded, although I used the method of representation like view(1, 1, -1)?

Any help would be appreciated!

+4
source share
1 answer

embedded 3d-, hidden ( ), 3d-. hidden LSTM. PyTorch LSTM [h] [c] , .

, .

concatenated_output = torch.cat((embedded, hidden[0]), 1)
+2

Source: https://habr.com/ru/post/1672600/


All Articles