def alg2_VT(self, Qx, Qxprime, M): #K1, K2, K3
     B = T.outer(Qx, Qxprime)
     C = T.sqrt(B)# in R^{n*n}
     D = M / C  # this is lamblda in ReLU analyrucal formula
     E = np.clip(D, -1, 1) # clipping E between -1 and 1 for numerical stability.
     F = (1 / (2 * np.pi)) * (E * (np.pi - T.arccos(E)) + T.sqrt(1 - E ** 2)) * C
     G = (np.pi - T.arccos(E)) / (2 * np.pi)
     return F,G
Exemplo n.º 2
0
 def VT(self, M):
     A = T.diag(M)  # GP_old is in R^{n*n} having the output gp kernel
     # of all pairs of data in the data set
     B = A * A[:, None]
     C = T.sqrt(B)  # in R^{n*n}
     D = M / C  # this is lamblda in ReLU analyrucal formula
     E = T.clip(D, -1, 1)  # clipping E between -1 and 1 for numerical stability.
     F = (1 / (2 * np.pi)) * (E * (np.pi - T.arccos(E)) + T.sqrt(1 - E ** 2)) * C
     G = (np.pi - T.arccos(E)) / (2 * np.pi)
     return F,G
 def alg1_VT_dep(self, M): #here i will use M as the previous little q ////// NxN, same value for every row
     A = T.diag(M)  # GP_old is in R^{n*n} having the output gp kernel
     # of all pairs of data in the data set
     B = A * A[:, None]
     C = T.sqrt(B)  # in R^{n*n}
     D = M / C  # this is lambda in ReLU analyrucal formula (c in alg)
     E = T.clip(D, -1, 1)  # clipping E between -1 and 1 for numerical stability.
     F = (1 / (2 * np.pi)) * (E * (np.pi - T.arccos(E)) + T.sqrt(1 - E ** 2)) * C
     G = (np.pi - T.arccos(E)) / (2 * np.pi)
     return F,G
Exemplo n.º 4
0
def RNTK_relu(x, RNTK_old, GP_old, param, output):
    sw = param["sigmaw"]
    su = param["sigmau"]
    sb = param["sigmab"]
    sv = param["sigmav"]

    a = T.diag(GP_old)  # GP_old is in R^{n*n} having the output gp kernel
    # of all pairs of data in the data set
    B = a * a[:, None]
    C = T.sqrt(B)  # in R^{n*n}
    D = GP_old / C  # this is lamblda in ReLU analyrucal formula
    # clipping E between -1 and 1 for numerical stability.
    E = T.clip(D, -1, 1)
    F = (1 / (2 * np.pi)) * (E * (np.pi - T.arccos(E)) + T.sqrt(1 - E**2)) * C
    G = (np.pi - T.arccos(E)) / (2 * np.pi)
    if output:
        GP_new = sv**2 * F
        RNTK_new = sv**2.0 * RNTK_old * G + GP_new
    else:
        X = x * x[:, None]
        GP_new = sw**2 * F + (su**2 / m) * X + sb**2
        RNTK_new = sw**2.0 * RNTK_old * G + GP_new
    return RNTK_new, GP_new
Exemplo n.º 5
0
 def create_network(self, state):
     state = T.stack([T.arccos(state[:, 0]), state[:, 2]], 1)
     input = nn.relu(nn.layers.Dense(state, 32))
     input = nn.relu(nn.layers.Dense(input, 32))
     input = nn.layers.Dense(input, 1)
     return input