(flags)
Set default hyperparameters.
Set default hyperparameters.
Set default hyperparameters .
def set_flags(flags):
  """Set default hyperparameters."""
  # Must be specified externally
  flags.set_if_empty('train_root_dir', '/tmp/gansynth/train')
  flags.set_if_empty('train_data_path', '/tmp/gansynth/nsynth-train.tfrecord')

  ### Dataset ###
  flags.set_if_empty('dataset_name', 'nsynth_tfds')
  flags.set_if_empty('data_type', 'mel')  # linear, phase, mel
  flags.set_if_empty('audio_length', 64000)
  flags.set_if_empty('sample_rate', 16000)
  # specgrams_simple_normalizer, specgrams_freq_normalizer
  flags.set_if_empty('data_normalizer', 'specgrams_prespecified_normalizer')
  flags.set_if_empty('normalizer_margin', 0.8)
  flags.set_if_empty('normalizer_num_examples', 1000)
  flags.set_if_empty('mag_normalizer_a', 0.0661371661726)
  flags.set_if_empty('mag_normalizer_b', 0.113718730221)
  flags.set_if_empty('p_normalizer_a', 0.8)
  flags.set_if_empty('p_normalizer_b', 0.)

  ### Losses ###
  # Gradient norm target for wasserstein loss
  flags.set_if_empty('gradient_penalty_target', 1.0)
  flags.set_if_empty('gradient_penalty_weight', 10.0)
  # Additional penalty to keep the scores from drifting too far from zero
  flags.set_if_empty('real_score_penalty_weight', 0.001)
  # Auxiliary loss for conditioning
  flags.set_if_empty('generator_ac_loss_weight', 1.0)
  flags.set_if_empty('discriminator_ac_loss_weight', 1.0)
  # Weight of G&L consistency loss
  flags.set_if_empty('gen_gl_consistency_loss_weight', 0.0)

  ### Optimization ###
  flags.set_if_empty('generator_learning_rate', 0.0004)  # Learning rate
  flags.set_if_empty('discriminator_learning_rate', 0.0004)  # Learning rate
  flags.set_if_empty('adam_beta1', 0.0)  # Adam beta 1
  flags.set_if_empty('adam_beta2', 0.99)  # Adam beta 2
  flags.set_if_empty('fake_batch_size', 16)  # The fake image batch size

  ### Distributed Training ###
  flags.set_if_empty('master', '')  # Name of the TensorFlow master to use
  # The number of parameter servers. If the value is 0, then the parameters
  # are handled locally by the worker
  flags.set_if_empty('ps_tasks', 0)
  # The Task ID. This value is used when training with multiple workers to
  # identify each worker
  flags.set_if_empty('task', 0)

  ### Debugging ###
  flags.set_if_empty('debug_hook', False)

  ### -----------  HPARAM Settings for testing eval ###
  ### Progressive Training ###
  # A list of batch sizes for each resolution, if len(batch_size_schedule)
  # < num_resolutions, pad the schedule in the beginning with first batch size
  flags.set_if_empty('batch_size_schedule', [16, 8])
  flags.set_if_empty('stable_stage_num_images', 32)
  flags.set_if_empty('transition_stage_num_images', 32)
  flags.set_if_empty('total_num_images', 320)
  flags.set_if_empty('save_summaries_num_images', 100)
  flags.set_if_empty('train_progressive', True)
  # For fixed-wall-clock-time training, total training time limit in sec.
  # If specified, overrides the iteration limits.
  flags.set_if_empty('train_time_limit', None)
  flags.set_if_empty('train_time_stage_multiplier', 1.)

  ### Architecture ###
  # Choose an architecture function
  flags.set_if_empty('g_fn', 'specgram')  # 'specgram'
  flags.set_if_empty('d_fn', 'specgram')
  flags.set_if_empty('latent_vector_size', 256)
  flags.set_if_empty('kernel_size', 3)
  flags.set_if_empty('start_height', 4)  # Start specgram height
  flags.set_if_empty('start_width', 8)  # Start specgram width
  flags.set_if_empty('scale_mode', 'ALL')  # Scale mode ALL|H
  flags.set_if_empty('scale_base', 2)  # Resolution multiplier
  flags.set_if_empty('num_resolutions', 7)  # N progressive resolutions
  flags.set_if_empty('simple_arch', False)
  flags.set_if_empty('to_rgb_activation', 'tanh')
  # Number of filters
  flags.set_if_empty('fmap_base', 512)  # Base number of filters
  flags.set_if_empty('fmap_decay', 1.0)
  flags.set_if_empty('fmap_max', 128)
def set_flags ( flags ) : # Must be specified externally flags . set_if_empty ( 'train_root_dir' , '/tmp/gansynth/train' ) flags . set_if_empty ( 'train_data_path' , '/tmp/gansynth/nsynth-train.tfrecord' ) ### Dataset ### flags . set_if_empty ( 'dataset_name' , 'nsynth_tfds' ) flags . set_if_empty ( 'data_type' , 'mel' ) # linear, phase, mel flags . set_if_empty ( 'audio_length' , 64000 ) flags . set_if_empty ( 'sample_rate' , 16000 ) # specgrams_simple_normalizer, specgrams_freq_normalizer flags . set_if_empty ( 'data_normalizer' , 'specgrams_prespecified_normalizer' ) flags . set_if_empty ( 'normalizer_margin' , 0.8 ) flags . set_if_empty ( 'normalizer_num_examples' , 1000 ) flags . set_if_empty ( 'mag_normalizer_a' , 0.0661371661726 ) flags . set_if_empty ( 'mag_normalizer_b' , 0.113718730221 ) flags . set_if_empty ( 'p_normalizer_a' , 0.8 ) flags . set_if_empty ( 'p_normalizer_b' , 0. ) ### Losses ### # Gradient norm target for wasserstein loss flags . set_if_empty ( 'gradient_penalty_target' , 1.0 ) flags . set_if_empty ( 'gradient_penalty_weight' , 10.0 ) # Additional penalty to keep the scores from drifting too far from zero flags . set_if_empty ( 'real_score_penalty_weight' , 0.001 ) # Auxiliary loss for conditioning flags . set_if_empty ( 'generator_ac_loss_weight' , 1.0 ) flags . set_if_empty ( 'discriminator_ac_loss_weight' , 1.0 ) # Weight of G&L consistency loss flags . set_if_empty ( 'gen_gl_consistency_loss_weight' , 0.0 ) ### Optimization ### flags . set_if_empty ( 'generator_learning_rate' , 0.0004 ) # Learning rate flags . set_if_empty ( 'discriminator_learning_rate' , 0.0004 ) # Learning rate flags . set_if_empty ( 'adam_beta1' , 0.0 ) # Adam beta 1 flags . set_if_empty ( 'adam_beta2' , 0.99 ) # Adam beta 2 flags . set_if_empty ( 'fake_batch_size' , 16 ) # The fake image batch size ### Distributed Training ### flags . set_if_empty ( 'master' , '' ) # Name of the TensorFlow master to use # The number of parameter servers. If the value is 0, then the parameters # are handled locally by the worker flags . set_if_empty ( 'ps_tasks' , 0 ) # The Task ID. This value is used when training with multiple workers to # identify each worker flags . set_if_empty ( 'task' , 0 ) ### Debugging ### flags . set_if_empty ( 'debug_hook' , False ) ### -----------  HPARAM Settings for testing eval ### ### Progressive Training ### # A list of batch sizes for each resolution, if len(batch_size_schedule) # < num_resolutions, pad the schedule in the beginning with first batch size flags . set_if_empty ( 'batch_size_schedule' , [ 16 , 8 ] ) flags . set_if_empty ( 'stable_stage_num_images' , 32 ) flags . set_if_empty ( 'transition_stage_num_images' , 32 ) flags . set_if_empty ( 'total_num_images' , 320 ) flags . set_if_empty ( 'save_summaries_num_images' , 100 ) flags . set_if_empty ( 'train_progressive' , True ) # For fixed-wall-clock-time training, total training time limit in sec. # If specified, overrides the iteration limits. flags . set_if_empty ( 'train_time_limit' , None ) flags . set_if_empty ( 'train_time_stage_multiplier' , 1. ) ### Architecture ### # Choose an architecture function flags . set_if_empty ( 'g_fn' , 'specgram' ) # 'specgram' flags . set_if_empty ( 'd_fn' , 'specgram' ) flags . set_if_empty ( 'latent_vector_size' , 256 ) flags . set_if_empty ( 'kernel_size' , 3 ) flags . set_if_empty ( 'start_height' , 4 ) # Start specgram height flags . set_if_empty ( 'start_width' , 8 ) # Start specgram width flags . set_if_empty ( 'scale_mode' , 'ALL' ) # Scale mode ALL|H flags . set_if_empty ( 'scale_base' , 2 ) # Resolution multiplier flags . set_if_empty ( 'num_resolutions' , 7 ) # N progressive resolutions flags . set_if_empty ( 'simple_arch' , False ) flags . set_if_empty ( 'to_rgb_activation' , 'tanh' ) # Number of filters flags . set_if_empty ( 'fmap_base' , 512 ) # Base number of filters flags . set_if_empty ( 'fmap_decay' , 1.0 ) flags . set_if_empty ( 'fmap_max' , 128 )