def auxiliary_tot_cost(params_together): # here x, y are understood as global variables defined above b2, b3, b4, W2, W3, W4 = nn_potential.split_params(params_together) return nn_potential.total_cost(nn_potential.x, nn_potential.y, b2, b3, b4, W2, W3, W4, 10)
def auxiliary_gradient(params_together): b2, b3, b4, W2, W3, W4 = nn_potential.split_params(params_together) return nn_potential.grad_cost(nn_potential.x, nn_potential.y, b2, b3, b4, W2, W3, W4)
coeffi, coeffj = 2, 2 elif i == 22: coeffi, coeffj = 2, 3 plt.hist(centroids[:, i], bb, density=True, color='darkblue') plt.title('W4[' + str(coeffi) + ',' + str(coeffj) + ']') plt.grid(True) plt.suptitle("1d projections of the appoximated 23d energy landscape;" + \ " x: values, y: probabilities\nPeaks correspond to lower total cost") plt.show() # Perform gradient descent on each centroid to identify the modes print("\nSearching for the modes... ") modes_list = [] for i in range(ncent): print("Gradient descent on centroid number", i) b2, b3, b4, W2, W3, W4 = nn_potential.split_params(centroids[i]) if (nn_potential.performGradientDescent(nn_potential.x, nn_potential.y, b2, b3, b4, W2, W3, W4, eta=0.5)[0]): print("MODE FOUND: centroid number ", i) modes_list.append(i) # Now, plot all the energies for the modes found print("A total of " + str(len(modes_list)) + " modes have been found") d = len(modes_list)