本文整理汇总了Python中Model.Model.test方法的典型用法代码示例。如果您正苦于以下问题:Python Model.test方法的具体用法?Python Model.test怎么用?Python Model.test使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.test方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findIndexes
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import test [as 别名]
## 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?")
outputFile = open(OUT_PATH, "w")
outputFile.write("id,click\n")
i = 0
gen = testGenerator(SUB_PATH, NUM_TEST_BATCH, featCreators = funcs)
示例2: print
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import test [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()
示例3: enumerate
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import 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