当前位置: 首页>>代码示例>>Python>>正文


Python Model.tree_test方法代码示例

本文整理汇总了Python中Model.Model.tree_test方法的典型用法代码示例。如果您正苦于以下问题:Python Model.tree_test方法的具体用法?Python Model.tree_test怎么用?Python Model.tree_test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model.Model的用法示例。


在下文中一共展示了Model.tree_test方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: enumerate

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import tree_test [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
开发者ID:mohummedalee,项目名称:politeness,代码行数:31,代码来源:main.py


注:本文中的Model.Model.tree_test方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。