本文整理汇总了Python中dataset.Dataset.sampler方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.sampler方法的具体用法?Python Dataset.sampler怎么用?Python Dataset.sampler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.sampler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_wl
# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import sampler [as 别名]
wl = create_wl(fvocab)
print "word len", len(wl)
id2word = invert_dict(wl)
tl = {"O":0, "B-CM":1, "I-CM":2, "B-SD":3, "I-SD":4, "B-M":5, "I-M":6, "B-DC":7, "I-DC":8}
trainset = Dataset(path+train_w, path+train_t, wl, tl, batch_size)
devset = Dataset(path+dev_w, path+dev_t, wl, tl, batch_size)
testset = Dataset(path+test_w, path+test_t, wl, tl, batch_size)
print "trainset", trainset.tot
print "devset", devset.tot
print "testset", testset.tot
sampler = trainset.sampler()
dev_sampler = devset.sampler()
test_sampler = testset.sampler()
l_vocab_w = len(wl)
l_vocab_out=len(tl)
model = SLLModel(l_vocab_w = l_vocab_w, l_vocab_out = l_vocab_out, n_f = n_f, n_hidden = n_hidden, lr = lr, trainer = trainer, activation=T.tanh, model = model, viterbi = viterbi, fname = fname, wl = wl)
#train_res = []
j=1
for i in range(N):
if(i == 0):
continue
inputs, tags, = sampler.next()
res = model.train_perplexity(inputs[0],tags[0])