2017-10-15 3 views
0

私は、各レイヤーに2つのレイヤーと256のセルを持つLSTMを実装しようと考えています。私はPyTorchのLSTMフレームワークを理解しようとしています。私が編集できるtorch.nn.LSTMの変数は、input_size、hidden_​​size、num_layers、bias、batch_first、dropout、および双方向です。Pytorchで複数のセルを持つLSTMレイヤを実装する方法は?

ただし、1つのレイヤに複数のセルを配置するにはどうすればよいですか?

答えて

0

これらのセルは入力のシーケンスサイズに基づいて自動的に展開されます。このコードをチェックアウトしてください:

# One cell RNN input_dim (4) -> output_dim (2). sequence: 5, batch 3 
# 3 batches 'hello', 'eolll', 'lleel' 
# rank = (3, 5, 4) 
inputs = Variable(torch.Tensor([[h, e, l, l, o], 
           [e, o, l, l, l], 
           [l, l, e, e, l]])) 
print("input size", inputs.size()) # input size torch.Size([3, 5, 4]) 

# Propagate input through RNN 
# Input: (batch, seq_len, input_size) when batch_first=True 
# B x S x I 
out, hidden = cell(inputs, hidden) 
print("out size", out.size()) # out size torch.Size([3, 5, 2]) 

あなたはhttps://github.com/hunkim/PyTorchZeroToAll/でより多くの例を見つけることができます。

関連する問題