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


Python utils.layer_params_to_mat2d函数代码示例

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


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

示例1: testFullyConnectedLayerParamsTensorToMat2d

 def testFullyConnectedLayerParamsTensorToMat2d(self):
   with ops.Graph().as_default(), self.test_session() as sess:
     random_seed.set_random_seed(200)
     layer_params = self._fully_connected_layer_params()
     output = utils.layer_params_to_mat2d(layer_params[0])
     self.assertListEqual([2, 2], output.get_shape().as_list())
     self.assertAllClose(sess.run(output), np.array([[1., 2.], [4., 3.]]))
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:7,代码来源: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: 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

示例6: testConvLayerParamsTupleToMat2d

 def testConvLayerParamsTupleToMat2d(self):
   with ops.Graph().as_default():
     random_seed.set_random_seed(200)
     layer_params = self._conv_layer_params()
     output = utils.layer_params_to_mat2d(layer_params)
     self.assertListEqual([2 * 2 * 3 + 1, 4], output.get_shape().as_list())
开发者ID:AbhinavJain13,项目名称:tensorflow,代码行数:6,代码来源:utils_test.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.layer_params_to_mat2d函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。