RNN的恩怨情仇
【注】x的维度是input_size,对x做线性变换的权重Wih为(hidden_size,input_size)
hidden的size为hidden_size,对hidden做线性变换的权重Whh为(hidden_size,hidden_size。
他俩能拼接起来【 w1,w2】[h与x列拼接],输出结果的size为(hidden_size,1)
RNNcell()
batch_size = 1
seq_len = 3
input_size = 4
hidden_size = 2
cell = torch.nn.RNNCell(input_size= input_size,hidden_size=hidden_size)
hidden = torch.zeros(batch_size,hidden_size)
dataset = torch.randn(seq_len,batch_size,input_size)
print('dataset',dataset)
for idx,input in enumerate(dataset):
print('='*20,idx)
print("input",input)
print("input_size",input_size)
hidden = cell(input,hidden)
print('hiden_size',hidden_size)
print('hidden'