MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _block_orth

Method _block_orth

tensorflow/python/ops/init_ops.py:1074–1107  ·  view source on GitHub ↗

Construct a 3 x 3 kernel. Used to construct orthgonal kernel. Args: p1: A symmetric projection matrix. p2: A symmetric projection matrix. p3: A symmetric projection matrix. Returns: A 2 x 2 x 2 kernel. Raises: ValueError: If the dimensions of p1, p2 a

(self, p1, p2, p3)

Source from the content-addressed store, hash-verified

1072 for j in range(k2)]) for i in range(k1)])
1073
1074 def _block_orth(self, p1, p2, p3):
1075 """Construct a 3 x 3 kernel.
1076
1077 Used to construct orthgonal kernel.
1078
1079 Args:
1080 p1: A symmetric projection matrix.
1081 p2: A symmetric projection matrix.
1082 p3: A symmetric projection matrix.
1083
1084 Returns:
1085 A 2 x 2 x 2 kernel.
1086 Raises:
1087 ValueError: If the dimensions of p1, p2 and p3 are different.
1088 """
1089 p1_shape = p1.shape.as_list()
1090 if p1_shape != p2.shape.as_list() or p1_shape != p3.shape.as_list():
1091 raise ValueError("The dimension of the matrices must be the same.")
1092 n = p1_shape[0]
1093 eye = linalg_ops_impl.eye(n, dtype=self.dtype)
1094 kernel2x2x2 = {}
1095
1096 def matmul(p1, p2, p3):
1097 return math_ops.matmul(math_ops.matmul(p1, p2), p3)
1098
1099 def cast(i, p):
1100 """Return p or (1-p)."""
1101 return i * p + (1 - i) * (eye - p)
1102
1103 for i in [0, 1]:
1104 for j in [0, 1]:
1105 for k in [0, 1]:
1106 kernel2x2x2[i, j, k] = matmul(cast(i, p1), cast(j, p2), cast(k, p3))
1107 return kernel2x2x2
1108
1109 def _matrix_conv(self, m1, m2):
1110 """Matrix convolution.

Callers 1

_orthogonal_kernelMethod · 0.95

Calls 3

matmulFunction · 0.70
castFunction · 0.70
as_listMethod · 0.45

Tested by

no test coverage detected