<commit_before>import os
import scipy.misc
import numpy as np
import audio_reader
from model import DCGAN
from utils import pp, visualize, to_json
import tensorflow as tf
import json
import warnings
from datetime import datetime
from shutil import copyfile
flags = tf.app.flags
flags.DEFINE_integer("epoch", 25, "Epoch to train [25]")
flags.DEFINE_integer("save_every", 100, "save sample outputs every [100]")
flags.DEFINE_float("learning_rate", 0.0002, "Learning rate of for adam [0.0002]")
flags.DEFINE_float("beta1", 0.5, "Momentum term of adam [0.5]")
flags.DEFINE_integer("batch_size", 1, "The size of input batch waveforms [1]")
flags.DEFINE_integer("gen_size", 1, "How many batches to generate (generate mode only)")
flags.DEFINE_integer("sample_length", 4096, "The length of the waveforms, both input and output")
flags.DEFINE_integer("c_dim", 1, "Dimension of image color. [1]")
#flags.DEFINE_integer("z_dim", 100, "length of latent code. [100]")
flags.DEFINE_string("dataset", "wav", "The name of dataset ['wav']")
flags.DEFINE_string("data_dir", None, "Optional path to data directory")
flags.DEFINE_string("out_dir", None, "Directory name to save the output samples, checkpoint, log")
flags.DEFINE_string("checkpoint_dir", None, "Directory name to LOAD checkpoint, new checkpoints will be saved to out_dir/checkpoint")
flags.DEFINE_string("mode", 'generate', "running mode, has to be either train or generate")
flags.DEFINE_boolean("use_disc", False, "Whether to use mini-batch discrimination on the discriminator")
flags.DEFINE_boolean("visualize", False, "True for visualizing, False for nothing [False]")
flags.DEFINE_string("audio_params", None, 'JSON file with tune-specific parameters.')
FLAGS = flags.FLAGS

def main(_):
    STARTED_DATESTRING = "{0:%Y-%m-%dT%H-%M-%S}".format(datetime.now())
    pp.pprint(flags.FLAGS.__flags)

    assert FLAGS.mode in ('train','generate'), "mode must be 'train' or 'generate'!"
    if FLAGS.mode == 'train': 
        if FLAGS.out_dir is None:
            FLAGS.out_dir = 'out/train_'+STARTED_DATESTRING
            print('Using default out_dir {0}'.format(FLAGS.out_dir))
        else:
            if FLAGS.out_dir.endswith('/'): FLAGS.out_dir = FLAGS.out_dir[:-1]
        if FLAGS.checkpoint_dir is None:
            FLAGS.checkpoint_dir = FLAGS.out_dir+'/checkpoint'
    else: 
        if FLAGS.checkpoint_dir is None:
            raise Exception('Cannot generate: checkpoint {0} does not exist!'.format(FLAGS.checkpoint_dir))
        else:
            if FLAGS.checkpoint_dir.endswith('/'): FLAGS.checkpoint_dir=FLAGS.checkpoint_dir[:-1]
        if FLAGS.out_dir is None:
            FLAGS.out_dir = 'out/gene_'+STARTED_DATESTRING

    if not os.path.exists(FLAGS.out_dir):
        os.makedirs(FLAGS.out_dir)
        #import IPython; IPython.embed()
        if FLAGS.mode == 'train':
            os.makedirs(FLAGS.out_dir+'/samples')
            os.makedirs(FLAGS.out_dir+'/checkpoint')<commit_msg>Fixed name out directory such that TensorFlow does not throw the following exception<commit_after>import os
import scipy.misc
import numpy as np
import audio_reader
from model import DCGAN
from utils import pp, visualize, to_json
import tensorflow as tf
import json
import warnings
from datetime import datetime
from shutil import copyfile
flags = tf.app.flags
flags.DEFINE_integer("epoch", 25, "Epoch to train [25]")
flags.DEFINE_integer("save_every", 100, "save sample outputs every [100]")
flags.DEFINE_float("learning_rate", 0.0002, "Learning rate of for adam [0.0002]")
flags.DEFINE_float("beta1", 0.5, "Momentum term of adam [0.5]")
flags.DEFINE_integer("batch_size", 1, "The size of input batch waveforms [1]")
flags.DEFINE_integer("gen_size", 1, "How many batches to generate (generate mode only)")
flags.DEFINE_integer("sample_length", 4096, "The length of the waveforms, both input and output")
flags.DEFINE_integer("c_dim", 1, "Dimension of image color. [1]")
#flags.DEFINE_integer("z_dim", 100, "length of latent code. [100]")
flags.DEFINE_string("dataset", "wav", "The name of dataset ['wav']")
flags.DEFINE_string("data_dir", None, "Optional path to data directory")
flags.DEFINE_string("out_dir", None, "Directory name to save the output samples, checkpoint, log")
flags.DEFINE_string("checkpoint_dir", None, "Directory name to LOAD checkpoint, new checkpoints will be saved to out_dir/checkpoint")
flags.DEFINE_string("mode", 'generate', "running mode, has to be either train or generate")
flags.DEFINE_boolean("use_disc", False, "Whether to use mini-batch discrimination on the discriminator")
flags.DEFINE_boolean("visualize", False, "True for visualizing, False for nothing [False]")
flags.DEFINE_string("audio_params", None, 'JSON file with tune-specific parameters.')
FLAGS = flags.FLAGS

def main(_):
    STARTED_DATESTRING = "{0:%Y-%m-%dT%H:%M:%S}".format(datetime.now()).replace(":", "-")
    pp.pprint(flags.FLAGS.__flags)

    assert FLAGS.mode in ('train','generate'), "mode must be 'train' or 'generate'!"
    if FLAGS.mode == 'train': 
        if FLAGS.out_dir is None:
            FLAGS.out_dir = 'out/train_'+STARTED_DATESTRING
            print('Using default out_dir {0}'.format(FLAGS.out_dir))
        else:
            if FLAGS.out_dir.endswith('/'): FLAGS.out_dir = FLAGS.out_dir[:-1]
        if FLAGS.checkpoint_dir is None:
            FLAGS.checkpoint_dir = FLAGS.out_dir+'/checkpoint'
    else: 
        if FLAGS.checkpoint_dir is None:
            raise Exception('Cannot generate: checkpoint {0} does not exist!'.format(FLAGS.checkpoint_dir))
        else:
            if FLAGS.checkpoint_dir.endswith('/'): FLAGS.checkpoint_dir=FLAGS.checkpoint_dir[:-1]
        if FLAGS.out_dir is None:
            FLAGS.out_dir = 'out/gene_'+STARTED_DATESTRING

    if not os.path.exists(FLAGS.out_dir):
        os.makedirs(FLAGS.out_dir)
        #import IPython; IPython.embed()
        if FLAGS.mode == 'train':
            os.makedirs(FLAGS.out_dir+'/samples')
            os.makedirs(FLAGS.out_dir+'/checkpoint')
{'fraction_non_alphanumeric': 0.12764539243459425, 'fraction_numerical': 0.014997500416597235, 'mean_word_length': 4.283450704225352, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4849511', 'n_tokens_mistral': 2017, 'n_tokens_neox': 1851, 'n_words': 535}