当前位置: 首页>>代码示例>>Python>>正文


Python nn.zero_fraction函数代码示例

本文整理汇总了Python中tensorflow.python.ops.nn.zero_fraction函数的典型用法代码示例。如果您正苦于以下问题:Python zero_fraction函数的具体用法?Python zero_fraction怎么用?Python zero_fraction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了zero_fraction函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testZeroFraction

 def testZeroFraction(self):
   x_shape = [5, 17]
   x_np = np.random.randint(0, 2, size=x_shape).astype(np.float32)
   y_np = self._ZeroFraction(x_np)
   with self.test_session():
     x_tf = constant_op.constant(x_np)
     x_tf.set_shape(x_shape)
     y_tf = nn.zero_fraction(x_tf)
     y_tf_np = y_tf.eval()
   eps = 1e-8
   self.assertAllClose(y_tf_np, y_np, eps)
开发者ID:nickicindy,项目名称:tensorflow,代码行数:11,代码来源:nn_test.py

示例2: _compute_fraction_of_zero

def _compute_fraction_of_zero(variables):
  """Given a linear variables list, compute the fraction of zero weights.

  Args:
    variables: A list or list of list of variables

  Returns:
    The fraction of zeros (sparsity) in the linear model.
  """
  all_weight_vars = []
  for var_or_var_list in variables:
    var_list = nest.flatten(var_or_var_list)
    # Skip empty-lists associated with columns that created no Variables.
    if var_list:
      all_weight_vars += [array_ops.reshape(var, [-1]) for var in var_list]
  return nn.zero_fraction(array_ops.concat(all_weight_vars, axis=0))
开发者ID:ThunderQi,项目名称:tensorflow,代码行数:16,代码来源:linear.py

示例3: _compute_fraction_of_zero

def _compute_fraction_of_zero(cols_to_vars):
  """Given a linear cols_to_vars dict, compute the fraction of zero weights.

  Args:
    cols_to_vars: A dictionary mapping FeatureColumns to lists of tf.Variables
      like one returned from feature_column_lib.linear_model.

  Returns:
    The fraction of zeros (sparsity) in the linear model.
  """
  all_weight_vars = []
  for var_or_var_list in cols_to_vars.values():
    # Skip empty-lists associated with columns that created no Variables.
    if var_or_var_list:
      all_weight_vars += [
          array_ops.reshape(var, [-1]) for var in var_or_var_list
      ]
  return nn.zero_fraction(array_ops.concat(all_weight_vars, axis=0))
开发者ID:AnishShah,项目名称:tensorflow,代码行数:18,代码来源:linear.py

示例4: _add_layer_summary

def _add_layer_summary(value, tag):
  summary.scalar("%s/fraction_of_zero_values" % tag, nn.zero_fraction(value))
  summary.histogram("%s/activation" % tag, value)
开发者ID:Ajaycs99,项目名称:tensorflow,代码行数:3,代码来源:dnn_linear_combined.py

示例5: _add_hidden_layer_summary

 def _add_hidden_layer_summary(self, value, tag):
     # TODO(zakaria): Move this code to tf.learn and add test.
     logging_ops.scalar_summary("%s:fraction_of_zero_values" % tag, nn.zero_fraction(value))
     logging_ops.histogram_summary("%s:activation" % tag, value)
开发者ID:ninotoshi,项目名称:tensorflow,代码行数:4,代码来源:dnn_linear_combined.py

示例6: _add_hidden_layer_summary

def _add_hidden_layer_summary(value, tag):
  summary.scalar('%s/fraction_of_zero_values' % tag, nn.zero_fraction(value))
  summary.histogram('%s/activation' % tag, value)
开发者ID:Huoxubeiyin,项目名称:tensorflow,代码行数:3,代码来源:dnn.py

示例7: _add_hidden_layer_summary

def _add_hidden_layer_summary(value, tag):
  logging_ops.scalar_summary("%s/fraction_of_zero_values" % tag,
                             nn.zero_fraction(value))
  logging_ops.histogram_summary("%s/activation" % tag, value)
开发者ID:Jackhuang945,项目名称:tensorflow,代码行数:4,代码来源:dnn_linear_combined.py

示例8: _add_hidden_layer_summary

 def _add_hidden_layer_summary(self, value, tag):
   # TODO(zakaria): Move this code to tf.learn and add test.
   summary.scalar("%s/fraction_of_zero_values" % tag, nn.zero_fraction(value))
   summary.histogram("%s/activation" % tag, value)
开发者ID:1000sprites,项目名称:tensorflow,代码行数:4,代码来源:composable_model.py

示例9: testZeroFractionEmpty

 def testZeroFractionEmpty(self):
   with self.test_session():
     x = np.zeros(0)
     y = nn.zero_fraction(x).eval()
     self.assertTrue(np.isnan(y))
开发者ID:nickicindy,项目名称:tensorflow,代码行数:5,代码来源:nn_test.py


注:本文中的tensorflow.python.ops.nn.zero_fraction函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。