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


Python Model.train方法代码示例

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


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

示例1: interactive_demo

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import train [as 别名]
def interactive_demo(X_train_files, y_train_files, C, gamma, epsilon):
    print 'Zapocinje ucenje modela'

    X_train = []
    y_train = []
    for file in X_train_files:
        X_train.extend(load_data_X(file))
    for file in y_train_files:
        y_train.extend(load_data_y(file))

    model = Model()
    model.train(X_train, y_train, True, C, gamma, epsilon)

    print 'Ucenje modela je zavrseno'

    while True:
        print 'Unesite 1. recenicu:'
        x1 = raw_input().decode(sys.stdin.encoding or locale.getpreferredencoding(True))
        print 'Unesite 2. recenicu:'
        x2 = raw_input().decode(sys.stdin.encoding or locale.getpreferredencoding(True))

        x = [x1, x2]
        y = model.predict(x)[0]
        print clamp(y, 0, 5)
开发者ID:kbiscanic,项目名称:apt_project,代码行数:26,代码来源:Main.py

示例2: print

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import train [as 别名]
##
##    end = time.time()
##    print("Time spent this iteration:", end-start, "seconds.")
##
##
##plt.plot(list(range(15,26)), scores)
##plt.show()

numEpochs = 5
scores = []
featExp = 23
for alpha in range(20,40):
    learningRate = alpha / 10000000
    start = time.time()
    
    numFeatures = 2**featExp
    M = Model(numFeatures, learningRate)
    print("Training.")
    M.train(TRAINPATH, TRAINNUMBATCH, TRAINSIZEBATCH, numEpochs)
    print("Testing.")
    target, prediction = M.test(TESTPATH, TESTNUMBATCH, TESTSIZEBATCH)
    score = M.score(target, prediction)
    scores.append(score)

    end = time.time()
    print("Time spent this iteration:", end-start, "seconds.")


plt.plot(list(range(1,100,10)), scores)
plt.show()
开发者ID:EtienneDesticourt,项目名称:Kaggle-Avazu,代码行数:32,代码来源:parameterTunner.py

示例3: range

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import train [as 别名]
##funcs = []
##for i in range(1):
##    i = 3
##    print(feat1[i],feat2[i])
##    funcs.append(createInteractionFunc(feat1[i],feat2[i]))

i, j = findIndexes(8)
funcs = []#[removeFeats, createInteractionFunc(i, j)]

if load == "t":
    Class = Model(NFEATURES, ALPHA, NEPOCHS, mustShuffle=True)
    #TRAINING
    print("Starting training.")
    generator = baseGenerator(PATH, NUM_BATCH_TRAIN, SIZE_BATCH, featCreators=funcs)
    Class.train(generator, v=True)

    #TESTING
    print("Starting testing.")
    generator = baseGenerator(TEST_PATH, NUM_BATCH_TEST, SIZE_BATCH, featCreators=funcs)
    Class.test(generator, v=True)


else:
    classFile = open("class.pkl","rb")
    Class = pickle.load(classFile)


#WRITE SUBMISSION
input("Go on with submission?")
开发者ID:EtienneDesticourt,项目名称:Kaggle-Avazu,代码行数:31,代码来源:runNoSplit.py

示例4: enumerate

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

示例5: Tree

# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import train [as 别名]
target = target[:, np.newaxis]


tree = Tree()
tree.root = Node()
node = Node(np.random.rand(dim, 1))
tree.root.add_child(node)
node = Node()
tree.root.add_child(node)
node1 = Node(np.random.rand(dim, 1))
node.add_child(node1)
node1 = Node(np.random.rand(dim, 1))
node.add_child(node1)


tree1 = Tree()
tree1.root = Node()
node = Node(np.random.rand(dim, 1))
tree1.root.add_child(node)
node = Node()
tree1.root.add_child(node)
node1 = Node(np.random.rand(dim, 1))
node.add_child(node1)
node1 = Node(np.random.rand(dim, 1))
node.add_child(node1)

RNN = Model(dim)
RNN.trees.append(tree)
RNN.trees.append(tree1)
RNN.train()
开发者ID:mohummedalee,项目名称:politeness,代码行数:32,代码来源:neural.py


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