示例#1
0
def PyTorchBiLSTM(nO, nI, depth, dropout=0.2):
    import torch.nn
    from thinc.api import with_square_sequences
    from thinc.extra.wrappers import PyTorchWrapperRNN

    if depth == 0:
        return layerize(noop())
    model = torch.nn.LSTM(nI, nO // 2, depth, bidirectional=True, dropout=dropout)
    return with_square_sequences(PyTorchWrapperRNN(model))
示例#2
0
def PyTorchBiLSTM(nO, nI, depth, dropout=0.2):
    if depth == 0:
        return layerize(noop())
    model = torch.nn.LSTM(nI,
                          nO // 2,
                          depth,
                          bidirectional=True,
                          dropout=dropout)
    return with_square_sequences(PyTorchWrapperRNN(model))
示例#3
0
def TorchBiLSTMEncoder(config):
    import torch.nn
    from thinc.extra.wrappers import PyTorchWrapperRNN

    width = config["width"]
    depth = config["depth"]
    if depth == 0:
        return layerize(noop())
    return with_square_sequences(
        PyTorchWrapperRNN(torch.nn.LSTM(width, width // 2, depth, bidirectional=True))
    )
示例#4
0
文件: _ml.py 项目: spacy-io/spaCy
def PyTorchBiLSTM(nO, nI, depth, dropout=0.2):
    if depth == 0:
        return layerize(noop())
    model = torch.nn.LSTM(nI, nO // 2, depth, bidirectional=True, dropout=dropout)
    return with_square_sequences(PyTorchWrapperRNN(model))
示例#5
0
def PyTorchBiLSTM(nO, nI, depth):
    model = torch.nn.LSTM(nI, nO // 2, depth, bidirectional=True)
    return with_square_sequences(PyTorchWrapperRNN(model))
示例#6
0
def PyTorchBiLSTM(nO, nI, depth):
    model = torch.nn.LSTM(nI, nO // 2, depth, bidirectional=True)
    return with_square_sequences(PyTorchWrapperRNN(model))