gan_toy.py
def generate_image(true_dist, saveidx=None):
        """
        Generates and saves a plot of the true distribution, the generator, and the
        critic.
        """
        N_POINTS = 128
        RANGE = 3

        points = np.zeros((N_POINTS, N_POINTS, 2), dtype='float32')
        points[:,:,0] = np.linspace(-RANGE, RANGE, N_POINTS)[:,None]
        points[:,:,1] = np.linspace(-RANGE, RANGE, N_POINTS)[None,:]
        points = points.reshape((-1,2))
        samples, disc_map = session.run(
            [fake_data, disc_real],
            feed_dict={real_data:points}
        )
        disc_map = session.run(disc_real, feed_dict={real_data:points})

        plt.clf()

        fig = plt.gcf()
        fig.set_size_inches(7, 7)

        axes = plt.gca()
        axes.set_xlim([-2, 2])
        axes.set_ylim([-2, 2])

        x = y = np.linspace(-RANGE, RANGE, N_POINTS)
        plt.contour(x,y,disc_map.reshape((len(x), len(y))).transpose())

        plt.scatter(true_dist[:, 0], true_dist[:, 1], c='orange',  marker='+')
        plt.scatter(samples[:, 0],    samples[:, 1],    c='green', marker='+')

        saveidx = frame_index[0] if saveidx is None else saveidx

        plt.savefig('{}/frame_{}.pdf'.format(log_dir, saveidx), format="pdf")
        frame_index[0] += 1

        Generates and saves a plot of the true distribution, the generator, and the
        critic.
        
Generates and saves a plot of the true distribution, the generator, and the
critic.
Generates and saves a plot of the true distribution the generator and the critic .
def generate_image(true_dist, saveidx=None):
        N_POINTS = 128
        RANGE = 3
        points = np.zeros((N_POINTS, N_POINTS, 2), dtype='float32')
        points[:,:,0] = np.linspace(-RANGE, RANGE, N_POINTS)[:,None]
        points[:,:,1] = np.linspace(-RANGE, RANGE, N_POINTS)[None,:]
        points = points.reshape((-1,2))
        samples, disc_map = session.run(
            [fake_data, disc_real],
            feed_dict={real_data:points}
        )
        disc_map = session.run(disc_real, feed_dict={real_data:points})
        plt.clf()
        fig = plt.gcf()
        fig.set_size_inches(7, 7)
        axes = plt.gca()
        axes.set_xlim([-2, 2])
        axes.set_ylim([-2, 2])
        x = y = np.linspace(-RANGE, RANGE, N_POINTS)
        plt.contour(x,y,disc_map.reshape((len(x), len(y))).transpose())
        plt.scatter(true_dist[:, 0], true_dist[:, 1], c='orange',  marker='+')
        plt.scatter(samples[:, 0],    samples[:, 1],    c='green', marker='+')
        saveidx = frame_index[0] if saveidx is None else saveidx
        plt.savefig('{}/frame_{}.pdf'.format(log_dir, saveidx), format="pdf")
        frame_index[0] += 1
def generate_image ( true_dist , saveidx = None ) : N_POINTS = 128 RANGE = 3 points = np . zeros ( ( N_POINTS , N_POINTS , 2 ) , dtype = 'float32' ) points [ : , : , 0 ] = np . linspace ( - RANGE , RANGE , N_POINTS ) [ : , None ] points [ : , : , 1 ] = np . linspace ( - RANGE , RANGE , N_POINTS ) [ None , : ] points = points . reshape ( ( - 1 , 2 ) ) samples , disc_map = session . run ( [ fake_data , disc_real ] , feed_dict = { real_data : points } ) disc_map = session . run ( disc_real , feed_dict = { real_data : points } ) plt . clf ( ) fig = plt . gcf ( ) fig . set_size_inches ( 7 , 7 ) axes = plt . gca ( ) axes . set_xlim ( [ - 2 , 2 ] ) axes . set_ylim ( [ - 2 , 2 ] ) x = y = np . linspace ( - RANGE , RANGE , N_POINTS ) plt . contour ( x , y , disc_map . reshape ( ( len ( x ) , len ( y ) ) ) . transpose ( ) ) plt . scatter ( true_dist [ : , 0 ] , true_dist [ : , 1 ] , c = 'orange' , marker = '+' ) plt . scatter ( samples [ : , 0 ] , samples [ : , 1 ] , c = 'green' , marker = '+' ) saveidx = frame_index [ 0 ] if saveidx is None else saveidx plt . savefig ( '{}/frame_{}.pdf' . format ( log_dir , saveidx ) , format = "pdf" ) frame_index [ 0 ] += 1
Generates and saves a plot of the true distribution, the generator, and the
critic.
Generates and saves a plot of the true distribution the generator and the critic .
"""
        Generates and saves a plot of the true distribution, the generator, and the
        critic.
        """
true_dist
saveidx