Bi-LSTM with Attention (PyTorch 实现) - 简书
https://www.jianshu.com/p/0b298c66ce2eBi-LSTM with Attention (PyTorch 实现) 这里用Bi-LSTM + Attention机制实现一个简单的句子分类任务。 先导包. import torch import numpy as np import torch.nn as nn import torch.optim as optim import torch.nn.functional as F import matplotlib.pyplot as plt import torch.utils.data as Data device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')