| ²é¿´: 754 | »Ø¸´: 0 | ||
| ¡¾ÐüÉͽð±Ò¡¿»Ø´ð±¾ÌûÎÊÌ⣬×÷Õßyang_12345½«ÔùËÍÄú 5 ¸ö½ð±Ò | ||
yang_12345гæ (³õÈëÎÄ̳)
|
[ÇóÖú]
Tensorflow×Ô°éÌØÕ÷·Ö½â²»³É¹¦£¬ÊäÈë¿ÉÄÜÎÞЧ
|
|
|
Self-adjoint eigen decomposition was not successful. The input might not be valid(Tensorflow×Ô°éÌØÕ÷·Ö½â²»³É¹¦£¬ÊäÈë¿ÉÄÜÎÞЧ) def cca_loss(outdim_size, use_all_singular_values): def inner_cca_objective(y_true, y_pred): r1 = 1e-4 r2 = 1e-4 eps = 1e-12 print("y_pred:",y_pred.shape[1]) o1 = o2 = int(y_pred.shape[1] // 2) print(y_pred) print("aaaa",o1,o2) # unpack (separate) the output of networks for view 1 and view 2 H1 = tf.transpose(y_pred[:, 0 1])H2 = tf.transpose(y_pred[:, o1 1 + o2])m = tf.shape(H1)[1] H1bar = H1 - tf.cast(tf.divide(1, m), tf.float32) * tf.matmul(H1, tf.ones([m, m])) H2bar = H2 - tf.cast(tf.divide(1, m), tf.float32) * tf.matmul(H2, tf.ones([m, m])) SigmaHat12 = tf.cast(tf.divide(1, m - 1), tf.float32) * tf.matmul(H1bar, H2bar, transpose_b=True) # [dim, dim] SigmaHat11 = tf.cast(tf.divide(1, m - 1), tf.float32) * tf.matmul(H1bar, H1bar, transpose_b=True) + r1 * tf.eye( o1) SigmaHat22 = tf.cast(tf.divide(1, m - 1), tf.float32) * tf.matmul(H2bar, H2bar, transpose_b=True) + r2 * tf.eye( o2) D1, V1 = tf.self_adjoint_eig(SigmaHat11) #ÇóÌØÕ÷Öµ ÌØÕ÷ÏòÁ¿ D2, V2 = tf.self_adjoint_eig(SigmaHat22) # Added to increase stability posInd1 = tf.where(tf.greater(D1, eps)) D1 = tf.gather_nd(D1, posInd1) # get eigen values that are larger than eps Ñ¡³ö´óÓÚepsµÄÌØÕ÷Öµ V1 = tf.transpose(tf.nn.embedding_lookup(tf.transpose(V1), tf.squeeze(posInd1))) posInd2 = tf.where(tf.greater(D2, eps)) D2 = tf.gather_nd(D2, posInd2) V2 = tf.transpose(tf.nn.embedding_lookup(tf.transpose(V2), tf.squeeze(posInd2))) SigmaHat11RootInv = tf.matmul(tf.matmul(V1, tf.diag(D1 ** -0.5)), V1, transpose_b=True) # [dim, dim] SigmaHat22RootInv = tf.matmul(tf.matmul(V2, tf.diag(D2 ** -0.5)), V2, transpose_b=True) Tval = tf.matmul(tf.matmul(SigmaHat11RootInv, SigmaHat12), SigmaHat22RootInv) print("use_all_singular_values",use_all_singular_values) if use_all_singular_values: corr = tf.sqrt(tf.trace(tf.matmul(Tval, Tval, transpose_a=True))) else: [U, V] = tf.self_adjoint_eig(tf.matmul(Tval, Tval, transpose_a=True)) U = tf.gather_nd(U, tf.where(tf.greater(U, eps))) kk = tf.reshape(tf.cast(tf.shape(U), tf.int32), []) K = tf.minimum(kk, outdim_size) w, _ = tf.nn.top_k(U, k=K) corr = tf.reduce_sum(tf.sqrt(w)) print("corr:",corr) return -corr return inner_cca_objective |
» ²ÂÄãϲ»¶
311Çóµ÷¼Á
ÒѾÓÐ6È˻ظ´
289Çóµ÷¼Á
ÒѾÓÐ25È˻ظ´
329Çóµ÷¼Á
ÒѾÓÐ10È˻ظ´
²ÄÁÏ¿¼Ñе÷¼Á
ÒѾÓÐ9È˻ظ´
327Çóµ÷¼Á
ÒѾÓÐ7È˻ظ´
²ÄÁÏ¿ÆÑ§Ó빤³Ìµ÷¼Á
ÒѾÓÐ18È˻ظ´
337Çóµ÷¼Á
ÒѾÓÐ11È˻ظ´
301Çóµ÷¼Á
ÒѾÓÐ5È˻ظ´
275Çóµ÷¼Á
ÒѾÓÐ11È˻ظ´
292Çóµ÷¼Á
ÒѾÓÐ14È˻ظ´














1])
»Ø¸´´ËÂ¥