LSTM中的hidden_dim和embed_size是什么意思?
What is the meaning of hidden_dim and embed_size in LSTM?
我正在尝试学习 RNN 和 LSTM。我浏览了一个情绪分析教程。下面是教程中的代码 I,其中 word2idx 是一个包含单词到索引映射的字典
class SentimentNet(nn.Module):
def __init__(self, vocab_size, output_size, embedding_dim, hidden_dim, n_layers, drop_prob=0.5):
super(SentimentNet, self).__init__()
self.output_size = output_size
self.n_layers = n_layers
self.hidden_dim = hidden_dim
self.embedding = nn.Embedding(vocab_size, embedding_dim)
self.lstm = nn.LSTM(embedding_dim, hidden_dim, n_layers, dropout=drop_prob, batch_first=True)
self.dropout = nn.Dropout(drop_prob)
self.fc = nn.Linear(hidden_dim, output_size)
self.sigmoid = nn.Sigmoid()
vocab_size = len(word2idx) + 1
output_size = 1
embedding_dim = 400
hidden_dim = 512
n_layers = 2
谁能告诉我vocal_size、embedding_dim、hidden_dim的意思?
递归神经网络 (LSTM),在其最基本的层面上,只是一种密集连接的神经网络。
隐藏维度基本上是每层中的节点数(例如在多层感知器中)
嵌入大小告诉您特征向量的大小(模型使用嵌入词作为输入)
我正在尝试学习 RNN 和 LSTM。我浏览了一个情绪分析教程。下面是教程中的代码 I,其中 word2idx 是一个包含单词到索引映射的字典
class SentimentNet(nn.Module):
def __init__(self, vocab_size, output_size, embedding_dim, hidden_dim, n_layers, drop_prob=0.5):
super(SentimentNet, self).__init__()
self.output_size = output_size
self.n_layers = n_layers
self.hidden_dim = hidden_dim
self.embedding = nn.Embedding(vocab_size, embedding_dim)
self.lstm = nn.LSTM(embedding_dim, hidden_dim, n_layers, dropout=drop_prob, batch_first=True)
self.dropout = nn.Dropout(drop_prob)
self.fc = nn.Linear(hidden_dim, output_size)
self.sigmoid = nn.Sigmoid()
vocab_size = len(word2idx) + 1
output_size = 1
embedding_dim = 400
hidden_dim = 512
n_layers = 2
谁能告诉我vocal_size、embedding_dim、hidden_dim的意思?
递归神经网络 (LSTM),在其最基本的层面上,只是一种密集连接的神经网络。
隐藏维度基本上是每层中的节点数(例如在多层感知器中)
嵌入大小告诉您特征向量的大小(模型使用嵌入词作为输入)