import tensorflow as tf

    hess = [] #list

    for i in range (dim):

        dg_i = tf.gradients(flat_grads[i], par) #for each element of grads evaluate the gradients
        dg_i_flat = flatten(dg_i) #flatten the resulting hessian onto a 1 d array
        hess.append(dg_i_flat) #store row by row

    return tf.reshape(hess,[dim, dim]) #returns the reshaped matrix


#=======================
#         Main
#=======================

def Run_DNN(X_train, Y_train, X_test, Y_test, layers, activation, epoch_sample, stdbeta, starter_learning, num_iterations, with_hessian, save_model, Plot):
