PermutationMatrix¶
-
class
tfsnippet.utils.
PermutationMatrix
(data)¶ Bases:
object
A non-trainable permutation matrix.
Attributes Summary
col_permutation
Get the column permutation indices. row_permutation
Get the row permutation indices. shape
Get the shape of this permutation matrix. Methods Summary
det
()Get the determinant of this permutation matrix. get_numpy_matrix
([dtype])Get the numpy permutation matrix. inv
()Get the inverse permutation matrix of this matrix. left_mult
(input[, name])Left multiply to input matrix. right_mult
(input[, name])Right multiply to input matrix. Attributes Documentation
-
col_permutation
¶ Get the column permutation indices.
Returns: The column permutation indices. Return type: tuple[int]
-
row_permutation
¶ Get the row permutation indices.
Returns: The row permutation indices. Return type: tuple[int]
-
shape
¶ Get the shape of this permutation matrix.
Returns: The shape of this permutation matrix. Return type: (int, int)
Methods Documentation
-
det
()¶ Get the determinant of this permutation matrix.
Returns: The determinant of this permutation matrix. Return type: float
-
get_numpy_matrix
(dtype=<type 'numpy.int32'>)¶ Get the numpy permutation matrix.
Parameters: dtype – The data type of the returned matrix. Returns: A 2-d numpy matrix. Return type: np.ndarray
-
inv
()¶ Get the inverse permutation matrix of this matrix.
Returns: The inverse permutation matrix. Return type: PermutationMatrix
-
left_mult
(input, name=None)¶ Left multiply to input matrix.
output = matmul(self, input)
Parameters: - input (np.ndarray or tf.Tensor) – The input matrix, whose
shape must be
(self.shape[1], ?)
. - name (str) – Default name of the name scope. If not specified, generate one according to the method name.
Returns: The result of multiplication.
Return type: np.ndarray or tf.Tensor
- input (np.ndarray or tf.Tensor) – The input matrix, whose
shape must be
-
right_mult
(input, name=None)¶ Right multiply to input matrix.
output = matmul(input, self)
Parameters: - input (np.ndarray or tf.Tensor) – The input matrix, whose
shape must be
(?, self.shape[0])
. - name (str) – Default name of the name scope. If not specified, generate one according to the method name.
Returns: The result of multiplication.
Return type: np.ndarray or tf.Tensor
- input (np.ndarray or tf.Tensor) – The input matrix, whose
shape must be
-