本文整理汇总了Python中Model.Model.tree_train方法的典型用法代码示例。如果您正苦于以下问题:Python Model.tree_train方法的具体用法?Python Model.tree_train怎么用?Python Model.tree_train使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.tree_train方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: enumerate
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import tree_train [as 别名]
for i, line in enumerate(fh):
p = line.find(' ')
ptb_string = line[p + 1:]
rid = line[:p]
# Add to the list of trees
RNN.add_tree(ptb_string, rid)
with open('rnn.pickle', 'wb') as pickle_file:
pickle.dump(RNN, pickle_file, pickle.HIGHEST_PROTOCOL)
else:
with open('rnn.pickle', 'rb') as pickle_file:
RNN = pickle.load(pickle_file)
indices = np.arange(0, training_size)
# create separate indices for the 3 data sets
np.random.shuffle(RNN.trees)
np.random.shuffle(indices)
RNN.tree_train = indices[:train]
RNN.tree_val = indices[train:train + val]
RNN.tree_test = indices[train + val:]
# print RNN.cross_validate()
RNN.train(True)
# RNN.check_model_veracity()
print "Test Cost Function, Accuracy, Incorrectly classified sentence Ids"
print RNN.test()
hyper_params = "training_size={0}\nl_rate={1}\nmini_batch_size={2}\nreg_cost={3}\nepochs={4}\ndim={5}".format(
training_size, l_rate, mini_batch_size, reg_cost, epochs, dim)
print hyper_params