本文整理汇总了Python中dataset.DataSet.load_sents方法的典型用法代码示例。如果您正苦于以下问题:Python DataSet.load_sents方法的具体用法?Python DataSet.load_sents怎么用?Python DataSet.load_sents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.DataSet
的用法示例。
在下文中一共展示了DataSet.load_sents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DataSet
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import load_sents [as 别名]
import numpy as np
from dataset import DataSet
from entailmentnet import HyperParameters, Net
from tensortree import Leaf
data = DataSet('wordpairs-v2.tsv')
data.load_sents('data-4')
# relu = np.vectorize(lambda x: max(0.,x) + 0.01 * min(0.,x))
relu = lambda x: np.maximum(x, np.zeros(x.shape) + 0.01 * np.minimum(x, np.zeros(x.shape)))
# relud = np.vectorize(lambda x: float(x>=0) + 0.01 * float(x<0))
relud = lambda x: (x >= 0).astype(float) + 0.01 * (x < 0).astype(float)
tanh = lambda x: np.tanh(x)
tanhd = lambda x: (1-(np.tanh(x)**2))
hyp = HyperParameters()
hyp.vocab_size = len(data.vocab)
hyp.word_size = 16
hyp.comparison_size = 20
hyp.classes = len(data.rels)
hyp.composition_transfer = tanh
hyp.composition_backtrans = tanhd
hyp.comparison_transfer = relu
hyp.comparison_backtrans = relud
hyp.batch_size = 35
hyp.l2_lambda = 0.0002
net = Net(hyp)
print net.dims
datapoints = [datapoint for dataset in data.sets.values() for datapoint in dataset]