def __init__(self, dp, charModel, wordModel, caseModel, inputSize, hiddenSize, layerNum, numTags): super(LSTM_CRF, self).__init__() self.dp = dp self.charModel = TimeDistributed(charModel, self.dp.char2Idx) self.wordModel = wordModel self.caseModel = caseModel self.lstm = nn.LSTM(inputSize, hiddenSize, layerNum, bias=0.5, batch_first=True, bidirectional=True) self.fc = nn.Linear(2 * hiddenSize, numTags),
def __init__(self, dp, charModel, wordModel, caseModel, featureModel, inputSize, hiddenSize, layerNum, dropout): super(AdaPULSTMCNN2, self).__init__() self.dp = dp self.charModel = TimeDistributed(charModel, self.dp.char2Idx) self.wordModel = wordModel self.caseModel = caseModel self.featureModel = featureModel self.lstm = nn.LSTM(inputSize, hiddenSize, num_layers=layerNum, batch_first=True, bidirectional=True) self.fc = nn.Sequential(nn.Linear(2 * hiddenSize, 200), nn.ReLU(), nn.Linear(200, 200), nn.ReLU(), nn.Linear(200, 200), nn.ReLU(), nn.Linear(200, 2), nn.Softmax(dim=2))
def __init__(self, dp, charModel, wordModel, caseModel, inputSize, hiddenSize, layerNum): super(SupervisedModel, self).__init__() self.dp = dp self.charModel = TimeDistributed(charModel, self.dp.char2Idx) self.wordModel = wordModel self.caseModel = caseModel self.lstm = nn.LSTM(inputSize, hiddenSize, layerNum, bias=0.5, batch_first=True, bidirectional=True) self.fc = nn.Sequential(nn.Linear(2 * hiddenSize, 200), nn.ReLU(), nn.Linear(200, 200), nn.ReLU(), nn.Linear(200, 200), nn.ReLU(), nn.Linear(200, 2)) self.loss = nn.CrossEntropyLoss()