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


Python sugartensor.reduce_mean方法代碼示例

本文整理匯總了Python中sugartensor.reduce_mean方法的典型用法代碼示例。如果您正苦於以下問題:Python sugartensor.reduce_mean方法的具體用法?Python sugartensor.reduce_mean怎麽用?Python sugartensor.reduce_mean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sugartensor的用法示例。


在下文中一共展示了sugartensor.reduce_mean方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: sg_summary_loss

# 需要導入模塊: import sugartensor [as 別名]
# 或者: from sugartensor import reduce_mean [as 別名]
def sg_summary_loss(tensor, prefix='losses', name=None):
    r"""Register `tensor` to summary report as `loss`

    Args:
      tensor: A `Tensor` to log as loss
      prefix: A `string`. A prefix to display in the tensor board web UI.
      name: A `string`. A name to display in the tensor board web UI.

    Returns:
      None
    """
    # defaults
    prefix = '' if prefix is None else prefix + '/'
    # summary name
    name = prefix + _pretty_name(tensor) if name is None else prefix + name
    # summary statistics
    _scalar(name, tf.reduce_mean(tensor))
    _histogram(name + '-h', tensor) 
開發者ID:buriburisuri,項目名稱:sugartensor,代碼行數:20,代碼來源:sg_logging.py

示例2: sg_summary_metric

# 需要導入模塊: import sugartensor [as 別名]
# 或者: from sugartensor import reduce_mean [as 別名]
def sg_summary_metric(tensor, prefix='metrics', name=None):
    r"""Register `tensor` to summary report as `metric`

    Args:
      tensor: A `Tensor` to log as metric
      prefix: A `string`. A prefix to display in the tensor board web UI.
      name: A `string`. A name to display in the tensor board web UI.

    Returns:
      None
    """
    # defaults
    prefix = '' if prefix is None else prefix + '/'
    # summary name
    name = prefix + _pretty_name(tensor) if name is None else prefix + name
    # summary statistics
    _scalar(name, tf.reduce_mean(tensor))
    _histogram(name + '-h', tensor) 
開發者ID:buriburisuri,項目名稱:sugartensor,代碼行數:20,代碼來源:sg_logging.py

示例3: sg_summary_gradient

# 需要導入模塊: import sugartensor [as 別名]
# 或者: from sugartensor import reduce_mean [as 別名]
def sg_summary_gradient(tensor, gradient, prefix=None, name=None):
    r"""Register `tensor` to summary report as `gradient`

    Args:
      tensor: A `Tensor` to log as gradient
      gradient: A 0-D `Tensor`. A gradient to log
      prefix: A `string`. A prefix to display in the tensor board web UI.
      name: A `string`. A name to display in the tensor board web UI.

    Returns:
        None
    """
    # defaults
    prefix = '' if prefix is None else prefix + '/'
    # summary name
    name = prefix + _pretty_name(tensor) if name is None else prefix + name
    # summary statistics
    # noinspection PyBroadException
    _scalar(name + '/grad', tf.reduce_mean(tf.abs(gradient)))
    _histogram(name + '/grad-h', tf.abs(gradient)) 
開發者ID:buriburisuri,項目名稱:sugartensor,代碼行數:22,代碼來源:sg_logging.py

示例4: sg_summary_activation

# 需要導入模塊: import sugartensor [as 別名]
# 或者: from sugartensor import reduce_mean [as 別名]
def sg_summary_activation(tensor, prefix=None, name=None):
    r"""Register `tensor` to summary report as `activation`

    Args:
      tensor: A `Tensor` to log as activation
      prefix: A `string`. A prefix to display in the tensor board web UI.
      name: A `string`. A name to display in the tensor board web UI.

    Returns:
      None
    """
    # defaults
    prefix = '' if prefix is None else prefix + '/'
    # summary name
    name = prefix + _pretty_name(tensor) if name is None else prefix + name
    # summary statistics
    _scalar(name + '/ratio',
            tf.reduce_mean(tf.cast(tf.greater(tensor, 0), tf.sg_floatx)))
    _histogram(name + '/ratio-h', tensor) 
開發者ID:buriburisuri,項目名稱:sugartensor,代碼行數:21,代碼來源:sg_logging.py

示例5: sg_mean

# 需要導入模塊: import sugartensor [as 別名]
# 或者: from sugartensor import reduce_mean [as 別名]
def sg_mean(tensor, opt):
    r"""Computes the mean of elements across axis of a tensor.
    
    See `tf.reduce_mean()` in tensorflow.

    Args:
      tensor: A `Tensor` (automatically given by chain).
      opt:
        axis : A tuple/list of integers or an integer. The axis to reduce.
        keep_dims: If true, retains reduced dimensions with length 1.
        name: If provided, replace current tensor's name.

    Returns:
      A `Tensor`.
    """
    return tf.reduce_mean(tensor, axis=opt.axis, keep_dims=opt.keep_dims, name=opt.name) 
開發者ID:buriburisuri,項目名稱:sugartensor,代碼行數:18,代碼來源:sg_transform.py

示例6: sg_regularizer_loss

# 需要導入模塊: import sugartensor [as 別名]
# 或者: from sugartensor import reduce_mean [as 別名]
def sg_regularizer_loss(scale=1.0):
    r""" Get regularizer losss

    Args:
      scale: A scalar. A weight applied to regularizer loss
    """
    return scale * tf.reduce_mean(tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES))

# Under construction
# def sg_tsne(tensor, meta_file='metadata.tsv', save_dir='asset/tsne'):
#     r""" Manages arguments of `tf.sg_opt`.
#
#     Args:
#         save_dir: A string. The root path to which checkpoint and log files are saved.
#           Default is `asset/train`.
#     """
#
#     # make directory if not exist
#     if not os.path.exists(save_dir):
#         os.makedirs(save_dir)
#
#     # checkpoint saver
#     saver = tf.train.Saver()
#
#     # summary writer
#     summary_writer = tf.summary.FileWriter(save_dir, graph=tf.get_default_graph())
#
#     # embedding visualizer
#     config = projector.ProjectorConfig()
#     emb = config.embeddings.add()
#     emb.tensor_name = tensor.name   # tensor
#     # emb.metadata_path = os.path.join(save_dir, meta_file)   # metadata file
#     projector.visualize_embeddings(summary_writer, config)
#
#     # create session
#     sess = tf.Session()
#     # initialize variables
#     sg_init(sess)
#
#     # save tsne
#     saver.save(sess, save_dir + '/model-tsne')
#
#     # logging
#     tf.sg_info('Tsne saved at %s' % (save_dir + '/model-tsne'))
#
#     # close session
#     sess.close() 
開發者ID:buriburisuri,項目名稱:sugartensor,代碼行數:49,代碼來源:sg_train.py


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