예제 #1
0
 def plot_samples(loop):
     with loop.timeit('plot_time'):
         images = session.run(x_plots)
         save_images_collection(images=images,
                                filename='plotting/{}.png'.format(
                                    loop.epoch),
                                grid_size=(10, 10))
예제 #2
0
 def plot_samples(loop):
     with loop.timeit('plot_time'):
         images = session.run(x_plots, feed_dict={is_training: False})
         save_images_collection(images=images,
                                filename=results.prepare_parent(
                                    'plotting/{}.png'.format(loop.epoch)),
                                grid_size=(10, 10))
예제 #3
0
 def plot_samples(loop):
     with loop.timeit('plot_time'):
         images = session.run(x_plots, feed_dict={is_training: False})
         save_images_collection(images=images,
                                filename='plotting/{}.png'.format(
                                    loop.epoch),
                                grid_size=(config.n_clusters, 10),
                                results=results)
예제 #4
0
 def plot_samples(loop):
     with loop.timeit('plot_time'):
         session = get_default_session_or_error()
         images = session.run(x_plots, feed_dict={is_training: False})
         save_images_collection(images=images,
                                filename='plotting/{}.png'.format(
                                    loop.epoch),
                                grid_size=(10, 10),
                                results=results)
예제 #5
0
 def plot_samples(loop):
     with loop.timeit('plot_time'):
         images = session.run(x_plots)
         save_images_collection(
             images=images,
             filename='plotting/{}.png'.format(loop.epoch),
             grid_size=(10, 10),
             results=results,
             channels_last=config.channels_last,
         )
예제 #6
0
 def plot_samples(loop):
     with loop.timeit('plot_time'):
         session = spt.utils.get_default_session_or_error()
         images = session.run(x_plots)
         save_images_collection(
             images=images,
             filename='plotting/{}.png'.format(loop.epoch),
             grid_size=(10, 10),
             results=results
         )
예제 #7
0
    def plot_samples(loop):
        with loop.timeit('plot_time'):
            try:
                # plot reconstructs
                for [x] in reconstruct_train_flow:
                    x_samples = uniform_sampler.sample(x)
                    images = np.zeros((300,) + config.x_shape, dtype=np.uint8)
                    images[::3, ...] = np.round(256.0 * x / 2 + 127.5)
                    images[1::3, ...] = np.round(256.0 * x_samples / 2 + 127.5)
                    images[2::3, ...] = np.round(session.run(
                        reconstruct_plots, feed_dict={input_x: x}))
                    batch_reconstruct_z = session.run(reconstruct_z, feed_dict={input_x: x})
                    # print(np.mean(batch_reconstruct_z ** 2, axis=-1))
                    save_images_collection(
                        images=images,
                        filename='plotting/train.reconstruct/{}.png'.format(loop.epoch),
                        grid_size=(20, 15),
                        results=results,
                    )
                    break

                # plot reconstructs
                for [x] in reconstruct_test_flow:
                    x_samples = uniform_sampler.sample(x)
                    images = np.zeros((300,) + config.x_shape, dtype=np.uint8)
                    images[::3, ...] = np.round(256.0 * x / 2 + 127.5)
                    images[1::3, ...] = np.round(256.0 * x_samples / 2 + 127.5)
                    images[2::3, ...] = np.round(session.run(
                        reconstruct_plots, feed_dict={input_x: x}))
                    save_images_collection(
                        images=images,
                        filename='plotting/test.reconstruct/{}.png'.format(loop.epoch),
                        grid_size=(20, 15),
                        results=results,
                    )
                    break
                # plot samples
                [images, gan_images, batch_history_e_z, batch_history_z, batch_history_pure_e_z,
                 batch_history_ratio] = session.run(
                    [x_plots, gan_plots, plot_history_e_z, plot_history_z, plot_history_pure_e_z, plot_history_ratio])
                # print(batch_history_e_z)
                # print(np.mean(batch_history_z ** 2, axis=-1))
                # print(batch_history_pure_e_z)
                # print(batch_history_ratio)
                save_images_collection(
                    images=np.round(gan_images),
                    filename='plotting/sample/gan-{}.png'.format(loop.epoch),
                    grid_size=(10, 10),
                    results=results,
                )
                save_images_collection(
                    images=np.round(images),
                    filename='plotting/sample/{}.png'.format(loop.epoch),
                    grid_size=(10, 10),
                    results=results,
                )
            except Exception as e:
                print(e)
예제 #8
0
    def plot_samples(loop):
        with loop.timeit('plot_time'):
            # plot samples
            images = session.run(x_plots)
            # pyplot.scatter(z_points[:, 0], z_points[:, 1], s=5)
            # pyplot.savefig(results.system_path('plotting/z_plot/{}.pdf'.format(loop.epoch)))
            # pyplot.close()
            # print(images)
            try:
                print(np.max(images), np.min(images))
                images = np.round(images)
                save_images_collection(
                    images=images,
                    filename='plotting/sample/{}.png'.format(loop.epoch),
                    grid_size=(10, 10),
                    results=results,
                )

                # plot reconstructs
                for [x] in reconstruct_train_flow:
                    x_samples = uniform_sampler.sample(x)
                    images = np.zeros((150, ) + config.x_shape, dtype=np.uint8)
                    images[::3, ...] = np.round(256.0 * x / 2 + 127.5)
                    images[1::3, ...] = np.round(256.0 * x_samples / 2 + 127.5)
                    images[2::3, ...] = np.round(
                        session.run(reconstruct_plots, feed_dict={input_x: x}))
                    save_images_collection(
                        images=images,
                        filename='plotting/train.reconstruct/{}.png'.format(
                            loop.epoch),
                        grid_size=(10, 15),
                        results=results,
                    )
                    break

                # plot reconstructs
                for [x] in reconstruct_test_flow:
                    x_samples = uniform_sampler.sample(x)
                    images = np.zeros((150, ) + config.x_shape, dtype=np.uint8)
                    images[::3, ...] = np.round(256.0 * x / 2 + 127.5)
                    images[1::3, ...] = np.round(256.0 * x_samples / 2 + 127.5)
                    images[2::3, ...] = np.round(
                        session.run(reconstruct_plots, feed_dict={input_x: x}))
                    save_images_collection(
                        images=images,
                        filename='plotting/test.reconstruct/{}.png'.format(
                            loop.epoch),
                        grid_size=(10, 15),
                        results=results,
                    )
                    break
            except Exception as e:
                print(e)