import torch1import numpy as np23# Random seed to make results deterministic and reproducible4torch.manual_seed(0)56# declare dimension7input_size = 48hidden_size = 2910# singleton example11# shape : (1, 1, 4)12# input_data_np = np.array([[[1, 0, 0, 0]]])1314# sequential example15# shape : (3, 5, 4)16h = [1, 0, 0, 0]17e = [0, 1, 0, 0]18l = [0, 0, 1, 0]19o = [0, 0, 0, 1]20input_data_np = np.array([[h, e, l, l, o], [e, o, l, l, l], [l, l, e, e, l]], dtype=np.float32)2122# transform as torch tensor23input_data = torch.Tensor(input_data_np)2425# declare RNN26rnn = torch.nn.RNN(input_size, hidden_size)2728# check output29outputs, _status = rnn(input_data)30print(outputs)31print(outputs.size())323334