本文整理汇总了Python中tensorflow.merge_summary方法的典型用法代码示例。如果您正苦于以下问题:Python tensorflow.merge_summary方法的具体用法?Python tensorflow.merge_summary怎么用?Python tensorflow.merge_summary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow
的用法示例。
在下文中一共展示了tensorflow.merge_summary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: define_summaries
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def define_summaries(self):
'''Helper function for init_opt'''
all_sum = {'g': [], 'd': [], 'hr_g': [], 'hr_d': [], 'hist': []}
for k, v in self.log_vars:
if k.startswith('g'):
all_sum['g'].append(tf.scalar_summary(k, v))
elif k.startswith('d'):
all_sum['d'].append(tf.scalar_summary(k, v))
elif k.startswith('hr_g'):
all_sum['hr_g'].append(tf.scalar_summary(k, v))
elif k.startswith('hr_d'):
all_sum['hr_d'].append(tf.scalar_summary(k, v))
elif k.startswith('hist'):
all_sum['hist'].append(tf.histogram_summary(k, v))
self.g_sum = tf.merge_summary(all_sum['g'])
self.d_sum = tf.merge_summary(all_sum['d'])
self.hr_g_sum = tf.merge_summary(all_sum['hr_g'])
self.hr_d_sum = tf.merge_summary(all_sum['hr_d'])
self.hist_sum = tf.merge_summary(all_sum['hist'])
示例2: visualization
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def visualization(self, n):
fake_sum_train, superimage_train =\
self.visualize_one_superimage(self.fake_images[:n * n],
self.images[:n * n],
n, "train")
fake_sum_test, superimage_test =\
self.visualize_one_superimage(self.fake_images[n * n:2 * n * n],
self.images[n * n:2 * n * n],
n, "test")
self.superimages = tf.concat(0, [superimage_train, superimage_test])
self.image_summary = tf.merge_summary([fake_sum_train, fake_sum_test])
hr_fake_sum_train, hr_superimage_train =\
self.visualize_one_superimage(self.hr_fake_images[:n * n],
self.hr_images[:n * n, :, :, :],
n, "hr_train")
hr_fake_sum_test, hr_superimage_test =\
self.visualize_one_superimage(self.hr_fake_images[n * n:2 * n * n],
self.hr_images[n * n:2 * n * n],
n, "hr_test")
self.hr_superimages =\
tf.concat(0, [hr_superimage_train, hr_superimage_test])
self.hr_image_summary =\
tf.merge_summary([hr_fake_sum_train, hr_fake_sum_test])
示例3: testCanBeCalledMultipleTimes
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def testCanBeCalledMultipleTimes(self):
batch_size = 20
val_input_batch = [tf.zeros([2, 3, 4])]
lbl_input_batch = tf.ones([], dtype=tf.int32)
probs = np.array([0, 1, 0, 0, 0])
batches = tf.contrib.training.stratified_sample(
val_input_batch, lbl_input_batch, probs, batch_size, init_probs=probs)
batches += tf.contrib.training.stratified_sample(
val_input_batch, lbl_input_batch, probs, batch_size, init_probs=probs)
summary_op = tf.merge_summary(tf.get_collection(tf.GraphKeys.SUMMARIES))
with self.test_session() as sess:
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
sess.run(batches + (summary_op,))
coord.request_stop()
coord.join(threads)
示例4: create_summaries
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def create_summaries(self, verbose=2):
""" Create summaries with `verbose` level """
summ_collection = self.name + "_training_summaries"
if verbose in [3]:
# Summarize activations
activations = tf.get_collection(tf.GraphKeys.ACTIVATIONS)
summarize_activations(activations, summ_collection)
if verbose in [2, 3]:
# Summarize variable weights
summarize_variables(self.train_vars, summ_collection)
if verbose in [1, 2, 3]:
# Summarize gradients
summarize_gradients(self.grad, summ_collection)
self.summ_op = merge_summary(tf.get_collection(summ_collection))
示例5: summarize_variables
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def summarize_variables(train_vars=None, summary_collection="tflearn_summ"):
""" summarize_variables.
Arguemnts:
train_vars: list of `Variable`. The variable weights to monitor.
summary_collection: A collection to add this summary to and
also used for returning a merged summary over all its elements.
Default: 'tflearn_summ'.
Returns:
`Tensor`. Merge of all summary in 'summary_collection'
"""
if not train_vars: train_vars = tf.trainable_variables()
summaries.add_trainable_vars_summary(train_vars, "", "", summary_collection)
return merge_summary(tf.get_collection(summary_collection))
示例6: summarize
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def summarize(value, type, name, summary_collection="tflearn_summ"):
""" summarize.
A custom summarization op.
Arguemnts:
value: `Tensor`. The tensor value to monitor.
type: `str` among 'histogram', 'scalar'. The data monitoring type.
name: `str`. A name for this summary.
summary_collection: A collection to add this summary to and
also used for returning a merged summary over all its elements.
Default: 'tflearn_summ'.
Returns:
`Tensor`. Merge of all summary in 'summary_collection'.
"""
if tf012:
name = name.replace(':', '_')
summaries.get_summary(type, name, value, summary_collection)
return merge_summary(tf.get_collection(summary_collection))
示例7: __setup_ops
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def __setup_ops(self):
cross_entropy = -tf.reduce_sum(self.actual_class * tf.log(self.output))
self.summary = tf.scalar_summary(self.label, cross_entropy)
self.train_op = tf.train.AdamOptimizer(0.0001).minimize(cross_entropy)
self.merge_summaries = tf.merge_summary([self.summary])
correct_prediction = tf.equal(tf.argmax(self.output,1), tf.argmax(self.actual_class,1))
self.accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float"))
示例8: define_summaries
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def define_summaries(self):
'''Helper function for init_opt'''
all_sum = {'g': [], 'd': [], 'hist': []}
for k, v in self.log_vars:
if k.startswith('g'):
all_sum['g'].append(tf.scalar_summary(k, v))
elif k.startswith('d'):
all_sum['d'].append(tf.scalar_summary(k, v))
elif k.startswith('hist'):
all_sum['hist'].append(tf.histogram_summary(k, v))
self.g_sum = tf.merge_summary(all_sum['g'])
self.d_sum = tf.merge_summary(all_sum['d'])
self.hist_sum = tf.merge_summary(all_sum['hist'])
示例9: visualization
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def visualization(self, n):
fake_sum_train, superimage_train = \
self.visualize_one_superimage(self.fake_images[:n * n],
self.images[:n * n],
n, "train")
fake_sum_test, superimage_test = \
self.visualize_one_superimage(self.fake_images[n * n:2 * n * n],
self.images[n * n:2 * n * n],
n, "test")
self.superimages = tf.concat(0, [superimage_train, superimage_test])
self.image_summary = tf.merge_summary([fake_sum_train, fake_sum_test])
示例10: __init__
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def __init__(self, model, loss, train_step, update_summaries):
""" Creates constructor for an abstract learning setup """
self.model = model
self.loss = loss
self.train_step = train_step
self.update_summary = tf.merge_summary(update_summaries)
self.update_iter = 0
示例11: summarize_activations
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def summarize_activations(activations, summary_collection="tflearn_summ"):
""" summarize_activations.
Arguemnts:
activations: list of `Tensor`. The activations to monitor.
summary_collection: A collection to add this summary to and
also used for returning a merged summary over all its elements.
Default: 'tflearn_summ'.
Returns:
`Tensor`. Merge of all summary in 'summary_collection'
"""
summaries.add_activations_summary(activations, "", "", summary_collection)
return merge_summary(tf.get_collection(summary_collection))
示例12: summarize_gradients
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def summarize_gradients(grads, summary_collection="tflearn_summ"):
""" summarize_gradients.
Arguemnts:
grads: list of `Tensor`. The gradients to monitor.
summary_collection: A collection to add this summary to and
also used for returning a merged summary over all its elements.
Default: 'tflearn_summ'.
Returns:
`Tensor`. Merge of all summary in 'summary_collection'
"""
summaries.add_gradients_summary(grads, "", "", summary_collection)
return merge_summary(tf.get_collection(summary_collection))
示例13: _init_summaries
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def _init_summaries(self):
self.accuracy = tf.placeholder_with_default(0.0, shape=(), name='Accuracy')
self.accuracy_summary = tf.scalar_summary('Accuracy summary', self.accuracy)
self.f_pos_summary = tf.histogram_summary('f_pos', self.f_pos)
self.f_neg_summary = tf.histogram_summary('f_neg', self.f_neg)
self.loss_summary = tf.scalar_summary('Mini-batch loss', self.loss)
self.summary_op = tf.merge_summary(
[
self.f_pos_summary,
self.f_neg_summary,
self.loss_summary
]
)
示例14: __init__
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def __init__(self, config, scope):
self.scope = scope
self.config = config
self.global_step = tf.get_variable('global_step', shape=[], dtype='int32',
initializer=tf.constant_initializer(0), trainable=False)
# Define forward inputs here
N, M, JX, JQ, VW, VC, W = \
config.batch_size, config.max_num_sents, config.max_sent_size, \
config.max_ques_size, config.word_vocab_size, config.char_vocab_size, config.max_word_size
self.x = tf.placeholder('int32', [N, M, None], name='x')
self.cx = tf.placeholder('int32', [N, M, None, W], name='cx')
self.x_mask = tf.placeholder('bool', [N, M, None], name='x_mask')
self.q = tf.placeholder('int32', [N, JQ], name='q')
self.cq = tf.placeholder('int32', [N, JQ, W], name='cq')
self.q_mask = tf.placeholder('bool', [N, JQ], name='q_mask')
self.y = tf.placeholder('bool', [N, M, JX], name='y')
self.is_train = tf.placeholder('bool', [], name='is_train')
self.new_emb_mat = tf.placeholder('float', [None, config.word_emb_size], name='new_emb_mat')
# Define misc
self.tensor_dict = {}
# Forward outputs / loss inputs
self.logits = None
self.yp = None
self.var_list = None
# Loss outputs
self.loss = None
self._build_forward()
self._build_loss()
if config.mode == 'train':
self._build_ema()
self.summary = tf.merge_all_summaries()
self.summary = tf.merge_summary(tf.get_collection("summaries", scope=self.scope))
示例15: __init__
# 需要导入模块: import tensorflow [as 别名]
# 或者: from tensorflow import merge_summary [as 别名]
def __init__(self, inputs, outputs, summary_ops=None, summary_writer=None, session=None):
self._inputs = inputs if type(inputs) == list else [inputs]
self._outputs = outputs
# self._summary_op = tf.merge_summary(summary_ops) if type(summary_ops) == list else summary_ops
self._summary_op = tf.merge_summary(summary_ops) if type(summary_ops) == list else summary_ops
self._session = session or tf.get_default_session()
self._writer = summary_writer