• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python utils.mat2d_to_layer_params函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testMat2dToFullyConnectedLayerParamsTensor

  def testMat2dToFullyConnectedLayerParamsTensor(self):
    with ops.Graph().as_default(), self.test_session() as sess:
      random_seed.set_random_seed(200)
      vector_template = self._fully_connected_layer_params()[0]
      mat2d = array_ops.constant([[5., 4.], [3., 2.]])

      output = sess.run(utils.mat2d_to_layer_params(vector_template, mat2d))

      self.assertAllClose(output, np.array([[5., 4.], [3., 2.]]))
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:9,代码来源:utils_test.py


示例2: multiply_matpower

 def multiply_matpower(self, vector, exp):
   reshaped_vector = utils.layer_params_to_mat2d(vector)
   reshaped_out = self._output_factor.right_multiply_matpower(
       reshaped_vector, exp, self._output_damping_func)
   reshaped_out = self._input_factor.left_multiply_matpower(
       reshaped_out, exp, self._input_damping_func)
   if self._renorm_coeff != 1.0:
     renorm_coeff = math_ops.cast(self._renorm_coeff, dtype=reshaped_out.dtype)
     reshaped_out *= math_ops.cast(renorm_coeff**exp, dtype=reshaped_out.dtype)
   return utils.mat2d_to_layer_params(vector, reshaped_out)
开发者ID:PuchatekwSzortach,项目名称:tensorflow,代码行数:10,代码来源:fisher_blocks.py


示例3: multiply_inverse

 def multiply_inverse(self, vector):
   left_factor_inv = self._input_factor.get_inverse(self._input_damping)
   right_factor_inv = self._output_factor.get_inverse(self._output_damping)
   reshaped_vector = utils.layer_params_to_mat2d(vector)
   reshaped_out = math_ops.matmul(left_factor_inv,
                                  math_ops.matmul(reshaped_vector,
                                                  right_factor_inv))
   if self._renorm_coeff != 1.0:
     reshaped_out /= math_ops.cast(
         self._renorm_coeff, dtype=reshaped_out.dtype)
   return utils.mat2d_to_layer_params(vector, reshaped_out)
开发者ID:Crazyonxh,项目名称:tensorflow,代码行数:11,代码来源:fisher_blocks.py


示例4: multiply

 def multiply(self, vector):
   left_factor = self._input_factor.get_cov()
   right_factor = self._output_factor.get_cov()
   reshaped_vector = utils.layer_params_to_mat2d(vector)
   reshaped_out = (math_ops.matmul(reshaped_vector, right_factor) +
                   self._output_damping * reshaped_vector)
   reshaped_out = (math_ops.matmul(left_factor, reshaped_out) +
                   self._input_damping * reshaped_out)
   if self._renorm_coeff != 1.0:
     reshaped_out *= math_ops.cast(
         self._renorm_coeff, dtype=reshaped_out.dtype)
   return utils.mat2d_to_layer_params(vector, reshaped_out)
开发者ID:Crazyonxh,项目名称:tensorflow,代码行数:12,代码来源:fisher_blocks.py


示例5: testMat2dToFullyConnectedLayerParamsTuple

  def testMat2dToFullyConnectedLayerParamsTuple(self):
    with ops.Graph().as_default(), self.test_session() as sess:
      random_seed.set_random_seed(200)
      vector_template = self._fully_connected_layer_params()
      mat2d = array_ops.constant([[5., 4.], [3., 2.], [1., 0.]])

      output = sess.run(utils.mat2d_to_layer_params(vector_template, mat2d))

      self.assertIsInstance(output, tuple)
      self.assertEqual(len(output), 2)
      a, b = output
      self.assertAllClose(a, np.array([[5., 4.], [3., 2.]]))
      self.assertAllClose(b, np.array([1., 0.]))
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:13,代码来源:utils_test.py


示例6: multiply

  def multiply(self, vector):
    """Approximate damped Fisher-vector product.

    Args:
      vector: Tensor or 2-tuple of Tensors. if self._has_bias, Tensor of shape
        [input_size, output_size] corresponding to layer's weights. If not, a
        2-tuple of the former and a Tensor of shape [output_size] corresponding
        to the layer's bias.

    Returns:
      Tensor of the same shape, corresponding to the Fisher-vector product.
    """
    reshaped_vect = utils.layer_params_to_mat2d(vector)
    reshaped_out = reshaped_vect * (self._factor.get_cov() + self._damping)
    return utils.mat2d_to_layer_params(vector, reshaped_out)
开发者ID:dyoung418,项目名称:tensorflow,代码行数:15,代码来源:fisher_blocks.py


示例7: multiply

 def multiply(self, vector):
   reshaped_vect = utils.layer_params_to_mat2d(vector)
   reshaped_out = self._factor.left_multiply(
       reshaped_vect, self._damping)
   return utils.mat2d_to_layer_params(vector, reshaped_out)
开发者ID:QiangCai,项目名称:tensorflow,代码行数:5,代码来源:fisher_blocks.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.tensors_to_column函数代码示例发布时间:2022-05-27
下一篇:
Python utils.layer_params_to_mat2d函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap