コード例 #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
ファイル: _ml.py プロジェクト: Ernest-Macharia/chatbot-app
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
ファイル: pytorch_lstm_tagger.py プロジェクト: spacy-io/thinc
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))