當前位置: 首頁>>代碼示例>>Python>>正文


Python tensorflow.merge_summary方法代碼示例

本文整理匯總了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']) 
開發者ID:hanzhanggit,項目名稱:StackGAN,代碼行數:22,代碼來源:trainer.py

示例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]) 
開發者ID:hanzhanggit,項目名稱:StackGAN,代碼行數:26,代碼來源:trainer.py

示例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) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:21,代碼來源:sampling_ops_test.py

示例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)) 
開發者ID:limbo018,項目名稱:FRU,代碼行數:19,代碼來源:trainer.py

示例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)) 
開發者ID:limbo018,項目名稱:FRU,代碼行數:18,代碼來源:summarizer.py

示例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)) 
開發者ID:limbo018,項目名稱:FRU,代碼行數:23,代碼來源:summarizer.py

示例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")) 
開發者ID:unageanu,項目名稱:jiji-with-tensorflow-example,代碼行數:9,代碼來源:model.py

示例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']) 
開發者ID:hanzhanggit,項目名稱:StackGAN,代碼行數:16,代碼來源:trainer.py

示例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]) 
開發者ID:hanzhanggit,項目名稱:StackGAN,代碼行數:13,代碼來源:trainer.py

示例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 
開發者ID:lil-lab,項目名稱:blocks,代碼行數:10,代碼來源:abstract_learning.py

示例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)) 
開發者ID:limbo018,項目名稱:FRU,代碼行數:17,代碼來源:summarizer.py

示例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)) 
開發者ID:limbo018,項目名稱:FRU,代碼行數:17,代碼來源:summarizer.py

示例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
            ]
        ) 
開發者ID:chaitjo,項目名稱:personalized-dialog,代碼行數:17,代碼來源:model.py

示例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)) 
開發者ID:sld,項目名稱:convai-bot-1337,代碼行數:40,代碼來源:model.py

示例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 
開發者ID:locuslab,項目名稱:icnn,代碼行數:9,代碼來源:icnn.py


注:本文中的tensorflow.merge_summary方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。