本文整理汇总了Python中dragnn.python.visualization.trace_html方法的典型用法代码示例。如果您正苦于以下问题:Python visualization.trace_html方法的具体用法?Python visualization.trace_html怎么用?Python visualization.trace_html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dragnn.python.visualization
的用法示例。
在下文中一共展示了visualization.trace_html方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testMasterSpecJson
# 需要导入模块: from dragnn.python import visualization [as 别名]
# 或者: from dragnn.python.visualization import trace_html [as 别名]
def testMasterSpecJson(self):
visualization.trace_html(
_get_trace_proto_string(), master_spec=_get_master_spec())
widget = visualization.InteractiveVisualization()
widget.initial_html()
widget.show_trace(_get_trace_proto_string(), master_spec=_get_master_spec())
示例2: main
# 需要导入模块: from dragnn.python import visualization [as 别名]
# 或者: from dragnn.python.visualization import trace_html [as 别名]
def main(argv):
del argv # unused
# Constructs lexical resources for SyntaxNet in the given resource path, from
# the training data.
lexicon.build_lexicon(
lexicon_dir,
training_sentence,
training_corpus_format='sentence-prototext')
# Construct the ComponentSpec for tagging. This is a simple left-to-right RNN
# sequence tagger.
tagger = spec_builder.ComponentSpecBuilder('tagger')
tagger.set_network_unit(name='FeedForwardNetwork', hidden_layer_sizes='256')
tagger.set_transition_system(name='tagger')
tagger.add_fixed_feature(name='words', fml='input.word', embedding_dim=64)
tagger.add_rnn_link(embedding_dim=-1)
tagger.fill_from_resources(lexicon_dir)
master_spec = spec_pb2.MasterSpec()
master_spec.component.extend([tagger.spec])
hyperparam_config = spec_pb2.GridPoint()
# Build the TensorFlow graph.
graph = tf.Graph()
with graph.as_default():
builder = graph_builder.MasterBuilder(master_spec, hyperparam_config)
target = spec_pb2.TrainTarget()
target.name = 'all'
target.unroll_using_oracle.extend([True])
dry_run = builder.add_training_from_config(target, trace_only=True)
# Read in serialized protos from training data.
sentence = sentence_pb2.Sentence()
text_format.Merge(open(training_sentence).read(), sentence)
training_set = [sentence.SerializeToString()]
with tf.Session(graph=graph) as sess:
# Make sure to re-initialize all underlying state.
sess.run(tf.initialize_all_variables())
traces = sess.run(
dry_run['traces'], feed_dict={dry_run['input_batch']: training_set})
with open('dragnn_tutorial_1.html', 'w') as f:
f.write(visualization.trace_html(traces[0], height='300px').encode('utf-8'))