MCPcopy Create free account
hub / github.com/dblalock/bolt / _debug_rotation

Function _debug_rotation

experiments/python/product_quantize.py:202–219  ·  view source on GitHub ↗
(R)

Source from the content-addressed store, hash-verified

200
201
202def _debug_rotation(R):
203 D = np.max(R.shape)
204 identity = np.identity(D, dtype=np.float32)
205 RtR = np.dot(R.T, R)
206
207 R_det = np.linalg.det(RtR)
208 print "determinant of R*R: ", R_det
209 R_trace = np.trace(RtR)
210 print "trace of R*R, trace divided by D: {}, {}".format(R_trace, R_trace / D)
211 off_diagonal_abs_mean = np.mean(np.abs(RtR - identity))
212 print "mean(abs(off diagonals of R*R)): ", off_diagonal_abs_mean
213
214 if R_det < .999 or R_det > 1.001:
215 raise NumericalException("Bad determinant")
216 if R_trace < .999 * D or R_trace > 1.001 * D:
217 raise NumericalException("Bad trace")
218 if off_diagonal_abs_mean > .001:
219 raise NumericalException("Bad off-diagonals")
220
221
222def opq_rotate(X, R): # so other code need not know what to transpose

Callers

nothing calls this directly

Calls 5

NumericalExceptionClass · 0.85
traceMethod · 0.80
formatMethod · 0.80
dotMethod · 0.45
meanMethod · 0.45

Tested by

no test coverage detected