本文整理汇总了Python中brain.Brain.random_seed_sentence方法的典型用法代码示例。如果您正苦于以下问题:Python Brain.random_seed_sentence方法的具体用法?Python Brain.random_seed_sentence怎么用?Python Brain.random_seed_sentence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类brain.Brain
的用法示例。
在下文中一共展示了Brain.random_seed_sentence方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compare_iteration
# 需要导入模块: from brain import Brain [as 别名]
# 或者: from brain.Brain import random_seed_sentence [as 别名]
def compare_iteration(model_prefix, iterations, diversities, training_text, seed_sentence=None):
result = {}
index = 0
for requested_iteration in iterations:
for file_name in [x for x in os.listdir(data_path('')) if x.startswith(model_prefix)]:
try:
(runid, maxlen, step, lstm_size, rest) = file_name.split('-')
(dropout, iteration, rest) = rest.split('_')
if str(iteration) != str(requested_iteration):
continue
(maxlen, step, lstm_size, dropout) = (int(maxlen), int(step), int(lstm_size), float(dropout))
brain = Brain(maxlen=maxlen, lstm_size=lstm_size, dropout=dropout,
training_text=training_text)
seed_sentence = seed_sentence or brain.random_seed_sentence()
print 'sentence: ' + seed_sentence
print '---- loading model: ' + file_name
model = brain.load_model_with_prefix(file_name)
length = 340
for diversity in diversities:
generated = brain.generate_full(
model=model,
n=length,
diversity=diversity,
seed_sentence=seed_sentence)
result[(index, file_name, diversity)] = generated
index += 1
print generated
except:
print "Unexpected error with {}: {}".format(file_name, sys.exc_info()[1])
raise
for (ix, name, div), generated in sorted(result.iteritems()):
print "ix={}, model={}, div={}| {}".format(ix, name, div, generated.encode('utf-8'))