hieudd:

class UserEmbed(nn.Module): def init(self, user_count): super(UserEmbed, self).init() self.embed_word = nn.Sequential( nn.Embedding(user_count, MAX_SENTS), nn.Linear(MAX_SENTS, 200), nn.ReLU(), nn.Flatten()) self.embed_news = nn.Sequential( nn.Embedding(user_count, MAX_SENTS), nn.Linear(MAX_SENTS, 200), nn.ReLU(), nn.Flatten()) def forward(self, x): user_embedding_word = self.embed_word(x) user_embedding_news = self.embed_news(x) return (user_embedding_word, user_embedding_news)


class UserEmbed(nn.Module):
    def __init__(self, user_count):
        super(UserEmbed, self).__init__()
        self.commong = nn.Embedding(user_count, MAX_SENTS)
        self.fc_word = nn.Sequential(
            nn.Linear(MAX_SENTS, 200),
            nn.ReLU())
        self.fc_news = nn.Sequential(
            nn.Linear(MAX_SENTS, 200),
            nn.ReLU())
    def forward(self, x):
        emb = self.common(x)
        user_embedding_word = self.embed_word(emb)
        user_embedding_news = self.embed_news(emb)
        return (user_embedding_word, user_embedding_news)

since your output is [batch_size, num_neurons], there is no need for flatten, and in PyTorch, view() is more commonly used, not sure if there is an API called flatten now