本文整理汇总了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;未经允许,请勿转载。 |
请发表评论