Esempio n. 1
0
 def __init__(self, input_size, hidden_size, num_embeddings=128, CUDA=True):
     super(AttentionCell, self).__init__()
     self.i2h = nn.Linear(input_size, hidden_size, bias=False)
     self.h2h = nn.Linear(hidden_size, hidden_size)
     self.score = nn.Linear(hidden_size, 1, bias=False)
     self.rnn = nn.GRUCell(input_size + num_embeddings, hidden_size)
     self.hidden_size = hidden_size
     self.input_size = input_size
     self.num_embeddings = num_embeddings
     self.fracPickup = fracPickup(CUDA=CUDA)
Esempio n. 2
0
    def __init__(self, input_size, hidden_size, num_embeddings=128, CUDA=True):
        """

        :param input_size: 输入维度
        :param hidden_size: cell个数
        :param num_embeddings:
        :param CUDA: GPU支持
        """
        super(AttentionCell, self).__init__()
        self.i2h = nn.Linear(input_size, hidden_size, bias=False)
        self.h2h = nn.Linear(hidden_size, hidden_size)
        self.score = nn.Linear(hidden_size, 1, bias=False)
        self.rnn = nn.GRUCell(input_size + num_embeddings, hidden_size)
        self.hidden_size = hidden_size
        self.input_size = input_size
        self.num_embeddings = num_embeddings
        self.fracPickup = fracPickup(CUDA=CUDA)  # 论文中的FP方法,提高识别准确率