<jupyter_start><jupyter_text>A Test of A Simple GANWe'll try to distinguish between 2D vectors genereated from a normal distribution and those that aren't. This is for simplicity.  Notes* There has to be some way of getting variables whose scope is the discriminator, and those whose scope is the generator. This is because the losses can be functions of both. Right now we're passing in names to tf.layers, a fairly clunky way of doing this...<jupyter_code>def gen_real_normals(batch_size=50): 
    normals = np.random.multivariate_normal(np.array([0, 0]), cov=np.eye(2), size=batch_size)
    labels = np.repeat(np.array([[1.0, 0.0]]), batch_size, axis=0)
    return normals, labels
def gen_uniform_noise(batch_size=50): 
    vals =  np.random.uniform(low = 10, high = 20, size = batch_size * 2).reshape(batch_size, 2)
    labels = np.repeat(np.array([[0.0, 1.0]]), batch_size, axis=0)
    return vals, labels
def discriminator(input_batch, reuse=False): 
    if reuse:
        tf.get_variable_scope().reuse_variables()
    with tf.name_scope('discr'), tf.variable_scope(tf.get_variable_scope(), reuse=tf.AUTO_REUSE):
        out1 = tf.layers.dense(input_batch, 10, activation=tf.nn.relu, name='disc_1')
        logits = tf.layers.dense(out1, 2,  activation=tf.nn.softmax, name='disc_2')
        return logits
def generator(noise_batch, reuse=False): 
    if reuse:
        tf.get_variable_scope().reuse_variables()
    with tf.name_scope('genr_') as name_scopes, tf.variable_scope(tf.get_variable_scope(), reuse=tf.AUTO_REUSE):
        out1 = tf.layers.dense(noise_batch, 10, activation=tf.sigmoid, name='gen_1')
        out2 = tf.layers.dense(out1, 2, name='gen_2')
        return out2
x_placeholder = tf.placeholder("float", shape=[None, 2], name='x_placeholder')
noise_placeholder = tf.placeholder("float", shape=[None, 2], name='noise_placeholder')
real_labels = tf.placeholder("float", shape=[None, 2], name='real_labels_placeholder')
fake_labels = tf.placeholder("float", shape=[None, 2], name='fake_labels_placeholder')

z_gen = generator(noise_placeholder)
discr_x = discriminator(x_placeholder)
discr_g = discriminator(z_gen)



d_loss_real = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits = discr_x, labels=real_labels))
d_loss_fake = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits = discr_g, labels=fake_labels))
d_loss = d_loss_real + d_loss_fake

# Want logits of fake digits to match the "real" labels 
g_loss = tf.reduce_mean(tf.nn.sigmoid_cross_entropy_with_logits(logits = discr_g, labels=real_labels))

trainable_vars = tf.trainable_variables()
d_vars = [var for var in trainable_vars if 'disc_' in var.name]
g_vars = [var for var in trainable_vars if 'gen_' in var.name]

with tf.variable_scope(tf.get_variable_scope(), reuse=tf.AUTO_REUSE) as scope:
    d_trainer_fake = tf.train.AdamOptimizer(0.0001).minimize(d_loss_fake, var_list=d_vars)
    d_trainer_real = tf.train.AdamOptimizer(0.0001).minimize(d_loss_real, var_list=d_vars)

    # Train the generator
    # Decreasing from 0.004 in GitHub version
    g_trainer = tf.train.AdamOptimizer(0.0001).minimize(g_loss, var_list=g_vars)

init_op = tf.global_variables_initializer()
fake_losses = []
real_losses = []
gen_losses = []
gen_points_lists = []
gen_logits_lists = []
real_logits_lists = []
with tf.Session() as sess: 
    sess.run([init_op])
    test_z_noise, test_z_labels = gen_uniform_noise(200)
    test_real_pts, test_x_labels = gen_real_normals(200)
    
    for i in range(601): 
        for k in range(16): 
            # generate m fake data points from generator
            # generate m real data points 
            # train discriminator 
            z_noise, fake_pt_labels = gen_uniform_noise(16)
            x_real, real_pt_labels = gen_real_normals(16)
            fake_loss, real_loss, _, _ = sess.run([d_loss_fake, d_loss_real, d_trainer_fake, d_trainer_real], 
                                                   feed_dict = {x_placeholder: x_real, noise_placeholder: z_noise, 
                                                                real_labels: real_pt_labels, fake_labels: fake_pt_labels})
            
        for j in range(16): 
            # Train generator. 
            z_noise, fake_pt_labels = gen_uniform_noise(16)
            real_pt_labels = np.repeat(np.array([[1.0, 0.0]]), 16, axis=0)
            gen_loss, _ = sess.run([g_loss, g_trainer], 
                                    feed_dict = {noise_placeholder: z_noise, fake_labels: fake_pt_labels, 
                                                 real_labels: real_pt_labels})
        # Compute a test pass. 
        if i % 10 == 0: 
            gen_points, gen_logits, real_logits, fake_loss, real_loss, gen_loss = sess.run(
                [z_gen, discr_g, discr_x, d_loss_fake, d_loss_real, g_loss], 
                feed_dict = {x_placeholder: test_real_pts, noise_placeholder: test_z_noise, 
                            real_labels: test_x_labels, fake_labels: test_z_labels})
            
#             print('Step {}'.format(i))
            fake_losses.append(fake_loss)
            real_losses.append(real_loss)
            gen_losses.append(gen_loss)
            gen_points_lists.append(gen_points)
            gen_logits_lists.append(gen_logits)
            real_logits_lists.append(real_logits)
        # Print sometimes. 
            if i % 50 == 0: 
                print('Step: ', i)
                print('Fake loss: ', fake_loss)
                print('Real loss: ', real_loss)
                print('Gen loss: ', gen_loss)
import matplotlib.pyplot as plt
%matplotlib inline
plt.figure(figsize=(16, 12))
plt.plot(np.arange(len(fake_losses)), fake_losses, label='Fake Losses')
# plt.plot(np.arange(len(fake_losses)), real_losses, label='Real Losses')
plt.plot(np.arange(len(fake_losses)), gen_losses, label='Generator Losses')
plt.legend()
index_list = [0, 15, -15, -1]
# fake_losses = []
# real_losses = []
# gen_losses = []
# gen_points_lists = []
# gen_logits_lists = []
# real_logits_lists = []
np.mean(np.exp(real_logits_lists[-1])[:, 0] / np.sum(np.exp(real_logits_lists[-1]), axis=1))
plt.figure(figsize=(24, 18))
for i, index in enumerate(index_list): 
    plt.ylabel('After {} Training Steps'.format(index))
    
    ax1 = plt.subplot2grid((len(index_list), 4), (i, 0))
#         test_z_noise, test_z_labels = gen_uniform_noise(200)
#     test_real_pts, test_x_labels = gen_real_normals(200)
    ax1.set_title('Input Noise (Uniform)')
    ax1.scatter(test_z_noise[:, 0], test_z_noise[:, 1], c='red')
    
    ax2 = plt.subplot2grid((len(index_list), 4), (i, 1))
#         test_z_noise, test_z_labels = gen_uniform_noise(200)
#     test_real_pts, test_x_labels = gen_real_normals(200)
    ax2.set_title('Underlying Normal Distribution')
    ax2.scatter(test_real_pts[:, 0], test_real_pts[:, 1], c='green')
    
    ax3 = plt.subplot2grid((len(index_list), 4), (i, 2))
#     ax3.set_title()
#         test_z_noise, test_z_labels = gen_uniform_noise(200)
#     test_real_pts, test_x_labels = gen_real_normals(200)
    ax3.set_title('Network Output')
    ax3.scatter(gen_points_lists[index][:, 0], gen_points_lists[index][:, 1], c='blue')
    
    ax4 = plt.subplot2grid((len(index_list), 4), (i, 3))
    prob_gen_true = np.mean(gen_logits_lists[index][:, 0])
    prob_real_true = np.mean(np.exp(real_logits_lists[-1])[:, 0] / np.sum(np.exp(real_logits_lists[-1]), axis=1))
    ax4.set_title('Discriminator Confidence')
    ax4.bar(np.arange(0, 2), [prob_real_true, prob_gen_true], color=['green', 'blue'])<jupyter_output><empty_output><jupyter_text>GAN for Realz* Load Data* Forward pass * Compute losses * Train (backward pass) * Every 50 or so steps, compute test information and store.<jupyter_code>import magenta
sys.path.append('../arbitrary_image_stylization(modified)/')
import nza_model as transformer_model
from magenta.models.image_stylization import learning as learning_utils
from magenta.models.image_stylization import vgg
from data_processing_utils import * 
from arbitrary_image_stylization_losses import * 

# Imports for the model build (forward pass). 
# from magenta.models.arbitrary_image_stylization import nza_model as transformer_model
from magenta.models.image_stylization import ops
from tensorflow.contrib.slim.python.slim.nets import inception_v3<jupyter_output><empty_output><jupyter_text>Load Data<jupyter_code>path_to_tripled_data = '/Users/akhiljalan/Downloads/traindata3/train0/'
from data_processing_utils import *
content_path = path_to_tripled_data + 'content/'
style_path = path_to_tripled_data + 'style/'
test_content_path = '/Users/akhiljalan/Downloads/traindata3/test/content'
test_style_path = '/Users/akhiljalan/Downloads/traindata3/test/content'
def load_random_images(filepath, batch_size = 4): 
    img_names = os.listdir(filepath)

    # Create a set of random indices from [0, ..., len(img_names) - 1]
    if len(img_names) >= batch_size: 
        indices = np.random.choice(np.arange(len(img_names)), batch_size, replace=False)
    else: 
        indices = np.arange(len(img_names))

    # Load a single random image. 
    images = load_image(filepath + img_names[indices[0]], image_size=256)

    # Load the rest of the images, concatenating onto the images tensor. 
    for i in range(1, len(indices)): 
        index = indices[i]
        next_img = load_image(filepath + img_names[index], image_size=256)
        images = tf.concat([images, next_img], axis=0)
    return images<jupyter_output><empty_output><jupyter_text>Forward Pass<jupyter_code>import arbitrary_image_stylization_evaluate
import arbitrary_image_stylization_build_model as build_model
with tf.Graph().as_default():
    # Loads content images.
    eval_content_inputs_ = load_random_images(content_path)
    
    # Default style, content, and variation weights from magenta. 
    
    content_weights = {"vgg_16/conv3": 1}
    style_weights = {"vgg_16/conv1": 0.5e-3, "vgg_16/conv2": 0.5e-3,
                     "vgg_16/conv3": 0.5e-3, "vgg_16/conv4": 0.5e-3}
    total_variation_weight = 1e4
    
    # Loads evaluation style images.
    eval_style_inputs_ = load_random_images(style_path)

    

    # Computes stylized images.
    stylized_images, _, loss_dict, _ = build_model.build_model(
        eval_content_inputs_,
        eval_style_inputs_,
        trainable=False,
        is_training=False,
        reuse=True,
        inception_end_point='Mixed_6e',
        style_prediction_bottleneck=100,
        adds_losses=True,
        content_weights=content_weights,
        style_weights=style_weights,
        total_variation_weight=FLAGS.total_variation_weight)

    # Adds Image summaries to the tensorboard.
#     tf.summary.image('image/{}/0_eval_content_inputs'.format(FLAGS.eval_name),
#                      eval_content_inputs_, 3)
#     tf.summary.image('image/{}/1_eval_style_inputs'.format(FLAGS.eval_name),
#                      eval_style_inputs_, 3)
#     tf.summary.image('image/{}/2_eval_stylized_images'.format(FLAGS.eval_name),
#                      stylized_images, 3)

    metrics = {}
    for key, value in loss_dict.iteritems():
      metrics[key] = tf.metrics.mean(value)

    names_values, names_updates = slim.metrics.aggregate_metric_map(metrics)
    for name, value in names_values.iteritems():
      slim.summaries.add_scalar_summary(value, name, print_summary=True)
    eval_op = names_updates.values()
    num_evals = FLAGS.num_evaluation_styles / FLAGS.batch_size

    slim.evaluation.evaluation_loop(
        master=FLAGS.master,
        checkpoint_dir=FLAGS.checkpoint_dir,
        logdir=FLAGS.eval_dir,
        eval_op=eval_op,
        num_evals=num_evals,
        eval_interval_secs=FLAGS.eval_interval_secs)<jupyter_output><empty_output><jupyter_text>GAN in Slim<jupyter_code>import os
import sys
import time

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline


from tensorflow.examples.tutorials.mnist import input_data

import tensorflow as tf

slim = tf.contrib.slim
tf.logging.set_verbosity(tf.logging.INFO)

tf.set_random_seed(219)
np.random.seed(219)
# model = GAN_model(mode="train")
# model.build()

# # show info for trainable variables
# t_vars = tf.trainable_variables()
# slim.model_analyzer.analyze_vars(t_vars, print_info=True)

# with tf.control_dependencies(tf.get_collection(tf.GraphKeys.UPDATE_OPS, scope='Discriminator')):
#   opt_D_op = opt_D.minimize(model.loss_Discriminator, var_list=model.D_vars)
# with tf.control_dependencies(tf.get_collection(tf.GraphKeys.UPDATE_OPS, scope='Generator')):
#   opt_G_op = opt_G.minimize(model.loss_Generator, global_step=model.global_step,
#                             var_list=model.G_vars)<jupyter_output><empty_output><jupyter_text>Useful Functions* `load_image` loads an image given a path, and also crops it to a desired size* `form_image_grid` is nice for plots and whatnot...<jupyter_code>names = os.listdir(path_to_tripled_data + 'content/')
np.random.randint(low=0, high=len(names), size=4)
from data_processing_utils import *
load_xy_pairs(path_to_styled_images, path_to_styles, batch_size = 10, prob_of_real=1.0)
load_image(path_to_styles + 'stained/stained_0015.jpg', image_size=25)
img_tensor = load_image(path_to_styles + 'stained/stained_0015.jpg')
img_tensor
form_image_grid(img_tensor, [1, 1], [360, 640], 3)
from PIL import Image
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
%matplotlib inline
# with tf.Session() as sess: 
#     arr = sess.run([img_tensor])
# #     print(arr)
# #     print(len(arr))
# #     print(type(arr))
#     fig, a = plt.subplots(1, 2)
#     np_arr = np.array(arr).squeeze()
# #     Image.fromarray(np_arr, 'RGB').show()
#     #https://stackoverflow.com/questions/17111525/how-to-show-multiple-images-in-one-figure
    
#     a=fig.subplots()
# img = mpimg.imread('../_static/stinkbug.png')
# lum_img = img[:,:,0]
# imgplot = plt.imshow(lum_img)
# a.set_title('Before')
# plt.colorbar(ticks=[0.1,0.3,0.5,0.7], orientation ='horizontal')
#     a=fig.add_subplot(1,1,2)
# a=fig.add_subplot(1,2,2)
# imgplot = plt.imshow(lum_img)
# imgplot.set_clim(0.0,0.7)
# a.set_title('After')
# plt.colorbar(ticks=[0.1,0.3,0.5,0.7], orientation='horizontal')

#     plt.imshow(np_arr)
# #     plt.gcf().clear()
# #     plt.imshow(-1 * np_arr)
# #     print(.shape)<jupyter_output><empty_output><jupyter_text>Stuff with OS<jupyter_code>from data_processing_utils import *
load_xy_pairs(pbn_path, path_to_styled_images, batch_size=12)<jupyter_output><empty_output><jupyter_text>Network Architecture  TODO Programming1 Put everything into a Python file once it's cleaned up 2 Train the discriminator independently, and in a "correct" way with respect to Tf 3 Figure out how to update the generative model end to end  Complete Slim Steps Steps to a slim model (as according to `arbitrary_image_stylization_train.py`: 1 `with tf.Graph().as_default():`2 Declare device allocations, such as ```device = '/cpu:0' if not FLAGS.ps_tasks else '/job:worker/cpu:0'    with tf.device(        tf.train.replica_device_setter(FLAGS.ps_tasks, worker_device=device))```3 Get content, style inputs. Generally, load your inputs to the network.4 Forward pass, to get the output(s) and loss(es). 5 Declare your optimizer object, such as ```optimizer = tf.train.AdamOptimizer(FLAGS.learning_rate)```6 Train operation, such as: ```train_op = slim.learning.create_train_op(          total_loss,          optimizer,          clip_gradient_norm=FLAGS.clip_gradient_norm,          summarize_gradients=False)```7 Run training, such as```slim.learning.train(          train_op=train_op,          logdir=os.path.expanduser(FLAGS.train_dir),          master=FLAGS.master,          is_chief=FLAGS.task == 0,          number_of_steps=FLAGS.train_steps,          init_fn=init_sub_networks,          save_summaries_secs=FLAGS.save_summaries_secs,          save_interval_secs=FLAGS.save_interval_secs)```8 Run, as in `tf.app.run()`  Discriminator NetworkTODO: * Use leaky relu in every layer * Use batch normalization * Consider using an all-convolutional network<jupyter_code>train_real_path = '/Users/akhiljalan/Downloads/train0/content_train/'
train_fake_path = '/Users/akhiljalan/Downloads/train0/identity_train/'
test_real_path = '/Users/akhiljalan/Downloads/train0/content_test/'
test_fake_path = '/Users/akhiljalan/Downloads/train0/identity_test/'
load_xy_pairs(train_fake_path, train_real_path, batch_size=16)
# with tf.Graph().as_default(), tf.Session() as sess:
# tf.reset_default_graph()
# tf.reset_default_graph()

with tf.Graph().as_default() as graph, tf.Session() as sess:
    images, labels = load_xy_pairs(path_to_styled_images, pbn_path, batch_size=4)
    
#     global_step = tf.Variable(0, name='global_step',trainable=False)
    tf_global_step = tf.train.get_or_create_global_step()

    # TODO Create Test Set from a different directory. 
    
    #forward pass 
    def forward_pass(images): 
        conv1_out = slim.conv2d(images, 1, [5, 5], activation_fn=tf.nn.relu, scope='conv1')
        pool1_out = slim.max_pool2d(conv1_out, [2, 2], stride=2, scope='pool1')
        conv2_out = slim.conv2d(pool1_out, 1, [4, 4], stride=2, activation_fn=tf.nn.relu, scope='conv2')
        pool2_out = slim.max_pool2d(conv2_out, [6, 6], stride=3, padding='SAME', scope='pool2')
        flat_out = slim.flatten(pool2_out, scope='flatten3')
        fc1_out = slim.fully_connected(flat_out, 12, scope='fc1', activation_fn=tf.nn.relu)
        predictions = slim.fully_connected(fc1_out, 2, activation_fn=tf.nn.softmax)
        return predictions

    predictions = forward_pass(images) 
    
    # define optimizer, loss, etc. 
    optimizer = tf.train.AdamOptimizer(1e-4)
    cross_entropy_loss = slim.losses.softmax_cross_entropy(predictions, labels)
    
    # compute accuracy, where prediction is argmax 
    pred_classes = tf.argmax(predictions, axis=1)
    true_classes = tf.argmax(labels, axis=1)
    acc = slim.metrics.accuracy(pred_classes, true_classes)
    
    # compute confidence in more-probable class 
    confidence = tf.reduce_mean(tf.reduce_max(predictions, axis=1))
    
    train_op = slim.learning.create_train_op(cross_entropy_loss, 
                                             optimizer, 
                                             summarize_gradients=False, 
                                             global_step=tf_global_step) #false?
    
    # print stuff
    print('loss ', cross_entropy_loss)
    print('accuracy ', acc)
#     tf.summary.scalar('loss', cross_entropy_loss)
#     tf.summary.scalar('accuracy', acc)
    
#     if tf.train.global_step() % 50 == 0: 
    test_images, test_labels = load_xy_pairs(test_fake_path, test_real_path, batch_size=2)
#     with tf.variable_scope(tf.get_variable_scope(), reuse=False):
    test_predictions = forward_pass(test_images)
    test_loss = slim.losses.softmax_cross_entropy(test_predictions, test_labels)

    # compute accuracy, where prediction is argmax 
    pred_test_classes = tf.argmax(test_predictions, axis=1)
    true_test_classes = tf.argmax(test_labels, axis=1)
    test_acc = slim.metrics.accuracy(pred_test_classes, true_test_classes)

    test_confidence = tf.reduce_mean(tf.reduce_max(test_predictions, axis=1))

    # print stuff
    print('test loss ', test_loss)
    print('test acc ', test_acc)
    print('test confidence ', test_confidence)
        
        
#     tf.summary.scalar('confidence', confidence)
#     tf.summary.FileWriter('./logdir/', graph)
    
#     tf.summary.text('time', tf.Tensor(, dtype=str))
    # run training 
    
    
    slim.learning.train(
          train_op=train_op,
#           logdir='./logdir/',
#           master=FLAGS.master,
#           is_chief=FLAGS.task == 0,
          number_of_steps=10)
#           init_fn=tf.global_variables_initializer(),
#           save_summaries_secs=10)
#           save_interval_secs=FLAGS.save_interval_secs)
    
    
import datetime
# slim evaluation loop vs train loop? 

# slim.evaluation.evaluation_loop(
#         master=FLAGS.master,
#         checkpoint_dir=FLAGS.checkpoint_dir,
#         logdir=FLAGS.eval_dir,
#         eval_op=eval_op,
#         num_evals=num_evals,
#         eval_interval_secs=FLAGS.eval_interval_secs)
# tf.summary.scalar('accuracy', accuracy)

# ALL TF SUMMARY SHIT

# time_now = datetime.datetime.now().isoformat()
# experiment_name = 'my_experiment_{}'.format(params)
# merged = tf.summary.merge_all()
# train_writer = tf.summary.FileWriter('./logdir/train/{}'.format(experiment_name), sess.graph)
# test_writer  = tf.summary.FileWriter('./logdir/test/{}'.format(experiment_name), sess.graph)

# summary, acc = sess.run([merged, accuracy], feed_dict={x: mnist.test.images,
#                                                                y_: mnist.test.labels})
#         test_writer.add_summary(summary, step)
# with tf.Graph().as_default():

## Adding scalar summaries to the tensorboard.
# for key, value in loss_dict.iteritems():
#         tf.summary.scalar(key, value)

# Adding Image summaries to the tensorboard.
#       tf.summary.image('image/0_content_inputs', content_inputs_, 3)
#       tf.summary.image('image/1_style_inputs_orig', style_inputs_orig_, 3)
#       tf.summary.image('image/2_style_inputs_aug', style_inputs_, 3)
#       tf.summary.image('image/3_stylized_images', stylized_images, 3)

# Set up training
#       optimizer = tf.train.AdamOptimizer(FLAGS.learning_rate)
#       train_op = slim.learning.create_train_op(
#           total_loss,
#           optimizer,
#           clip_gradient_norm=FLAGS.clip_gradient_norm,
#           summarize_gradients=False)

# slim.learning.train(
#           train_op=train_op,
#           logdir=os.path.expanduser(FLAGS.train_dir),
#           master=FLAGS.master,
#           is_chief=FLAGS.task == 0,
#           number_of_steps=FLAGS.train_steps,
#           init_fn=init_sub_networks,
#           save_summaries_secs=FLAGS.save_summaries_secs,
#           save_interval_secs=FLAGS.save_interval_secs)
ls = ['aaa', 'bbb']
tf.__version__
# # visualize.py
# #
# # to run
# # $ python visualize.py
# #
# # to use TensorBoard
# # $ tensorboard --logdir ./
# #
# import tensorflow as tf
# import datetime
# from tensorflow.examples.tutorials.mnist import input_data

# mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)

# x = tf.placeholder(tf.float32, shape=[None, 784])

# W = tf.get_variable("weights1", shape=[784, 10],
#                     initializer=tf.glorot_uniform_initializer())

# b = tf.get_variable("bias1", shape=[10],
#                     initializer=tf.constant_initializer(0.1))

# y = tf.nn.relu(tf.matmul(x, W) + b)

# y_ = tf.placeholder(tf.float32, [None, 10])

# cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits=y, labels=y_)
# train_step = tf.train.GradientDescentOptimizer(0.001).minimize(cross_entropy)

# correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
# accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))

# sess = tf.InteractiveSession()

# tf.summary.scalar('accuracy', accuracy)

# time_string = datetime.datetime.now().isoformat()
# experiment_name = f"one_hidden_layer_1000_steps_{time_string}"

# merged = tf.summary.merge_all()
# train_writer = tf.summary.FileWriter(f'./train/{experiment_name}', sess.graph)
# test_writer  = tf.summary.FileWriter(f'./test/{experiment_name}', sess.graph)

# tf.global_variables_initializer().run()

# for step in range(1000):
#     print(f"training step: {step}")
#     if step % 10 == 0:
#         summary, acc = sess.run([merged, accuracy], feed_dict={x: mnist.test.images,
#                                                                y_: mnist.test.labels})
#         test_writer.add_summary(summary, step)
#         print(f'Step {step}; Model accuracy: {acc}')
#     else:
#         batch_xs, batch_ys = mnist.train.next_batch(100)
#         sess.run(train_step, feed_dict={x: batch_xs, y_:batch_ys})
#         summary = sess.run(merged, feed_dict={x: batch_xs,
#                                               y_: batch_ys})
#         train_writer.add_summary(summary, step)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11976271467684393, 'fraction_numerical': 0.01763046544428773, 'mean_word_length': 3.639530408006159, 'pattern_counts': {'":': 5, '<': 33, '<?xml version=': 0, '>': 34, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '368846', 'license': 'MIT', 'n_tokens_mistral': 8578, 'n_tokens_neox': 8174, 'n_words': 1485, 'path': 'gan/discriminator/discriminator-misc.ipynb', 'repo_name': 'akhiljalan/cs-194-project', 'size': '24106'}