mag_err = []
thetas = []

######################################
#########Opening saved data###########
######################################
pkl_file = open('./DATA/8by8lattices.pkl', 'rb')
allTlattices = pickle.load(pkl_file)
pkl_file.close()
#allTlattices contains 32 lists for each temperature
#Each list contains 5000 spin configurations
for index in index_set:
    temp = T_vals[index]
    lattices = allTlattices[index][-nsamples:]
    energy.append(get_energy(lattices))
    thetas.append(get_parameters.get_magnetization_direction(lattices))
    # sp_heat.append(get_specific_heat(lattices,temp))
    [[ax], mag_mean, mag_std] = get_mean_magnetization(lattices)
    mag.append(mag_mean)
    mag_err.append(mag_std)

#################################
######Observing vortices#########
#################################
# data=(get_vorticity_configuration(allTlattices[20][9999])) #first index indicates the temperature index, second index is a no between 1-10000
# im = plt.imshow(data, interpolation='none')
# plt.figure(figsize=(8,4))
# values=range(-7,8)
# colors = [ im.cmap(im.norm(value)) for value in values]
# patches = [ mpatches.Patch(color=colors[i], label="Level {l}".format(l=values[i]) ) for i in range(len(values)) ]
# plt.legend(handles=patches, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0. )
Beispiel #2
0
    mean_energy_data = []
    var_energy_data = []

    n = n_samples[1]
    if Is_train == False:
        f = open('./DATA/8by8lattices.pkl', 'rb')
        if (f.read(2) == '\x1f\x8b'):
            f.seek(0)
            gzip.GzipFile(fileobj=f)
        else:
            f.seek(0)
        training_data = pickle.load(f, encoding="latin1")
        training_data = np.reshape(training_data,(320000, 64))
    for i in range(0,n_samples[0],4):
        Magnetization           = get_parameters.get_mean_magnetization(gsample[i*n_samples[1]:(i+1)*n_samples[1]])
        Magnetization_direction = get_parameters.get_magnetization_direction(gsample[i*n_samples[1]:(i+1)*n_samples[1]])
        energy                  = get_parameters.get_energy(gsample[i*n_samples[1]:(i+1)*n_samples[1]])
        print(i)
        if Is_train == False:
            fig1 = plt.figure(1)
            plt.plot(zsample[:n_samples[1],1],Magnetization[0][0],label = (T_vals[i]))
            fig2 = plt.figure(2)
            plt.plot(zsample[:n_samples[1],1],Magnetization_direction,label = (T_vals[i]))
        if Is_train == True:
            lattices = np.array(training_data[i*10000:i*10000+n]).reshape(n,lattice_size,lattice_size)
            energy_data = get_parameters.get_energy(lattices)
            thetas_data = get_parameters.get_magnetization_direction(lattices)
            [mag_data,mag_mean,mag_std] = get_parameters.get_mean_magnetization(lattices)
            plt.subplot(3,1,1)
            plt.hist(Magnetization[0][0][i*n_samples[1]:(i+1)*n_samples[1]],bins =20,color='b',range=[0, 1],alpha=0.5)
            plt.hist(mag_data           ,bins =20,color='g',range=[0, 1],alpha=0.5)
Beispiel #3
0
 Gsample = sess.run(fully_connected_decoder1, feed_dict={z: zsample})
 Gsample2 = sess.run(fully_connected_decoder2,
                     feed_dict={fully_connected_decoder1: Gsample})
 gsample = sess.run(x_hat, feed_dict={fully_connected_decoder2: Gsample2})
 # Gsamplemu = sess.run(x_mu, feed_dict={fully_connected_decoder2: Gsample2})
 # Gsamplesig  = sess.run(x_log_sigma_sq,feed_dict={fully_connected_decoder2:Gsample2})
 # gsample = sess.run(tf.random_normal(shape = tf.shape(Gsamplemu) ,mean = Gsamplemu,stddev = tf.sqrt(tf.exp(Gsamplesig)), dtype = tf.float32 ))#tf.sqrt(tf.exp(Gsamplesig))
 # print(360*Gsamplemu[:10], Gsamplesig[:10])
 gsample = gsample.reshape(zsample.shape[0], lattice_size, lattice_size)
 print("Specific Heat %f")
 # for i in range(n_samples):
 # print(get_parameters.get_specific_heat(gsample[i],zsample[i]))
 print("Mean magnetization and its Standard Deviation")
 mean_magnetization = []
 Magnetization = get_parameters.get_mean_magnetization(gsample)
 Magnetization_direction = get_parameters.get_magnetization_direction(
     gsample)
 energy = get_parameters.get_energy(gsample)
 print(energy)
 if n_z == 1:
     plt.plot(zsample, Magnetization[0][0])  #all values
     plt.xlabel('Latent Variable value', fontsize=12)
     plt.ylabel('Magnetization of a single sample generated by the network',
                fontsize=10)
     plt.savefig('mag_vs_temp.png')
     plt.show()
     plt.plot(zsample, Magnetization_direction)
     plt.show()
     plt.hist(energy, bins=100)
     plt.savefig('energy_vs_LV.png')
     plt.show()
 elif n_z == 2:
Beispiel #4
0
    if Is_train == False:
        f = open('./DATA/16and16lattices.pkl', 'rb')
        if (f.read(2) == '\x1f\x8b'):
            f.seek(0)
            gzip.GzipFile(fileobj=f)
        else:
            f.seek(0)
        training_inputs = pickle.load(f, encoding="latin1")
        training_inputs = np.reshape(training_inputs,(n_temps*10000, lattice_size**2))
    for i in range(0,n_temps):
        t = np.repeat(B_vals[i],n_z*n).reshape(n,n_z)
        gsample = sess.run(generator(z,reuse=True,bs = n), feed_dict={z_rand:zsample,temp:t})
        gsample   = gsample.reshape(n,lattice_size,lattice_size)
        print(B_vals[i],  360*np.mean(gsample[0]),360*np.std(gsample[0]))
        Magnetization           = get_parameters.get_mean_magnetization(gsample)
        Magnetization_direction = get_parameters.get_magnetization_direction(gsample)
        energy                  = get_parameters.get_energy(gsample)
        if Is_train == k:
            fig1 = plt.figure(1)
            plt.plot(Magnetization[0][0],label = (B_vals[i]))
            fig2 = plt.figure(2)
            plt.plot(Magnetization_direction,label = (B_vals[i]))
        if Is_train == l:
            lattices = np.array(training_inputs[i*10000+8000:i*10000+n+8000]).reshape(n,lattice_size,lattice_size)
            energy_data = get_parameters.get_energy(lattices)
            thetas_data = get_parameters.get_magnetization_direction(lattices)
            [mag_data,mag_mean,mag_std]=get_parameters.get_mean_magnetization(lattices)

            mean_magnetization.append(Magnetization[1])
            var_magnetization.append(Magnetization[2])
            mean_magnetization_data.append(mag_mean)
Beispiel #5
0
                    stddev=tf.sqrt(tf.exp(-Gsamplesig)),
                    dtype=tf.float32))  #tf.sqrt(tf.exp(Gsamplesig))

    gsample = gsample.reshape(zsample.shape[0], lattice_size, lattice_size)

    print("Specific Heat %f")
    print(360 * np.mean(Gsamplemu), 360 * np.std(Gsamplemu))
    print(360 * np.mean(-1.0 * Gsamplesig))
    print("Mean magnetization and its Standard Deviation")

    # for i in range(n_samples):
    # print(get_parameters.get_specific_heat(gsample[i],zsample[i]))

    mean_magnetization = []
    Magnetization = get_parameters.get_mean_magnetization(gsample)
    Magnetization_direction = get_parameters.get_magnetization_direction(
        gsample)
    energy = get_parameters.get_energy(gsample)

    if n_z == 1:
        for d in range(n_samples[0]):
            plt.plot(zsample[:n_samples[1], 1],
                     Magnetization[0][0][d * n_samples[1]:(d + 1) *
                                         n_samples[1]],
                     label=d)  #all values
        plt.xlabel('Latent Variable value', fontsize=12)
        plt.ylabel('Magnetization of a single sample generated by the network',
                   fontsize=10)
        plt.legend()
        plt.show()
        for d in range(n_samples[0]):
            plt.plot(
mag=[]
mag_err=[]

######################################
#########Opening saved data###########
######################################
# pkl_file=open('./DATA/16by16lattices.pkl','rb')
allTlattices= data_loader.load_data_wrapper()#pickle.load(pkl_file)
# pkl_file.close()
#allTlattices contains 32 lists for each temperature
#Each list contains 5000 spin configurations
for index in index_set:
    temp=T_vals[index]
    lattices=allTlattices
    energy.append(get_energy(lattices))
    thetas = get_parameters.get_magnetization_direction(lattices)
    # sp_heat.append(get_specific_heat(lattices,temp))
    # [mag_mean,mag_std]=get_mean_magnetization(lattices)
    # mag.append(mag_mean)
    # mag_err.append(mag_std)

#################################
######Observing vortices#########
#################################
# data=(get_vorticity_configuration(allTlattices[20][9999])) #first index indicates the temperature index, second index is a no between 1-10000
# im = plt.imshow(data, interpolation='none')
# plt.figure(figsize=(8,4))
# values=range(-7,8)
# colors = [ im.cmap(im.norm(value)) for value in values]
# patches = [ mpatches.Patch(color=colors[i], label="Level {l}".format(l=values[i]) ) for i in range(len(values)) ]
# plt.legend(handles=patches, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0. )