本文整理汇总了Python中Kernel.Utils.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.serialize方法的具体用法?Python Utils.serialize怎么用?Python Utils.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kernel.Utils
的用法示例。
在下文中一共展示了Utils.serialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Word2Vec
# 需要导入模块: from Kernel import Utils [as 别名]
# 或者: from Kernel.Utils import serialize [as 别名]
from Kernel import Optimizer
from Kernel import Statistics
from Kernel import Utils
from gensim.models import Word2Vec
import logging
CORPUS = "./corpus_polaridad/"
if Config.VERBOSE: logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
## SAVE MODEL ##
sentences = Utils.get_sentences(CORPUS)
sentences = Preprocess.normalize_sentences(sentences,True,False,False,False,False,True,1)
model = Word2Vec([sentence for (sentence,cat) in sentences],min_count=Config.MIN_COUNT_W2V,size=Config.SIZE_W2V,window=Config.WINDOW_W2V)
sentences = FeatureExtractor.get_sentences_representation(sentences,model,Config.SENTENCE_REPRESENTATION)
Utils.serialize("dest.m",model)
Utils.serialize("sentences.m",sentences)
################
## STATISTICS ##
#sentences = Utils.get_sentences(CORPUS)
#sentences = Preprocess.normalize_sentences(sentences,True,False,False,False,False,True,1)
#Statistics.leaving_one_out_nearest(sentences,1)
#Statistics.leaving_one_out_supervised_classifier(sentences,Config.CLASSIFIER)
################
## TESTING PROJECT CLASSIFIER ##
model = Utils.unserialize("dest.m")[0]
sentences = Utils.unserialize("sentences.m")[0]
sentence = "??????"
sentence = Preprocess.normalize(sentence,True,False,False,False,False,True,1)