摘要: 1 import torch 2 from torch import nn, optim 3 from torch.autograd import Variable 4 import torch.nn.functional as F 5 6 CONTEXT_SIZE = 2 # 2 words to the left, 2 to the right 7 raw_text = "... 阅读全文
posted @ 2017-07-13 10:21 Joyce_song94 阅读(2194) 评论(0) 推荐(0) 编辑
摘要: 1 import torch 2 import torch.nn as nn 3 from torch.autograd import Variable 4 import torch.nn.functional as F 5 import torch.optim as optim 6 7 CONTEXT_SIZE = 2 # the same as wind... 阅读全文
posted @ 2017-07-13 09:53 Joyce_song94 阅读(1929) 评论(0) 推荐(0) 编辑
摘要: 1 import torch 2 import torch.nn as nn 3 from torch.autograd import Variable 4 5 word2id = {'hello': 0, 'world': 1} 6 # you have 2 words, and then need 5 dim each word 7 embeds = nn.Embedding... 阅读全文
posted @ 2017-07-13 08:43 Joyce_song94 阅读(3794) 评论(0) 推荐(0) 编辑