MODE = '256ary' # binary or 256ary MODEL = 'pixel_rnn' # either pixel_cnn or pixel_rnn DIM = 32 PIXEL_CNN_LAYERS = 4 LR = 2e-4 BATCH_SIZE = 100 N_CHANNELS = 1 HEIGHT = 28 WIDTH = 28 TIMES = ('iters', 10*500, 1000*500) lib.print_model_settings(locals().copy()) # inputs.shape: (batch size, n channels, height, width) if MODE=='256ary': inputs = T.itensor4('inputs') inputs_float = inputs.astype(theano.config.floatX) * lib.floatX(2./255) inputs_float -= lib.floatX(0.5) else: inputs = T.tensor4('inputs') inputs_float = inputs output = lib.ops.conv2d.Conv2D( 'InputConv', input_dim=N_CHANNELS, output_dim=DIM, filter_size=7,
# FOLDER_PREFIX/params: saves all checkpoint params as pkl # FOLDER_PREFIX/samples: keeps all checkpoint samples as wav # FOLDER_PREFIX/best: keeps the best parameters, samples, ... if not os.path.exists(FOLDER_PREFIX): os.makedirs(FOLDER_PREFIX) PARAMS_PATH = os.path.join(FOLDER_PREFIX, 'params') if not os.path.exists(PARAMS_PATH): os.makedirs(PARAMS_PATH) SAMPLES_PATH = os.path.join(FOLDER_PREFIX, 'samples') if not os.path.exists(SAMPLES_PATH): os.makedirs(SAMPLES_PATH) BEST_PATH = os.path.join(FOLDER_PREFIX, 'best') if not os.path.exists(BEST_PATH): os.makedirs(BEST_PATH) lib.print_model_settings(locals(), path=FOLDER_PREFIX, sys_arg=True) ### Import the data_feeder ### # Handling WHICH_SET from datasets.dataset import music_train_feed_epoch as train_feeder from datasets.dataset import music_valid_feed_epoch as valid_feeder from datasets.dataset import music_test_feed_epoch as test_feeder def load_data(data_feeder): """ Helper function to deal with interface of different datasets. `data_feeder` should be `train_feeder`, `valid_feeder`, or `test_feeder`. """ return data_feeder(WHICH_SET, BATCH_SIZE, SEQ_LEN, OVERLAP, Q_LEVELS, Q_ZERO, Q_TYPE)
CONV_FILTER_SIZE = 3 LATENT_DIM = 128 ALPHA_ITERS = 20000 VANILLA = False LR = 2e-4 BATCH_SIZE = 100 N_CHANNELS = 1 HEIGHT = 28 WIDTH = 28 TIMES = ('iters', 10*500, 1000*500) # TIMES = ('seconds', 60*30, 60*60*6) lib.print_model_settings(locals().copy()) theano_srng = RandomStreams(seed=234) def Encoder(inputs): if MODE=='256ary': embedded = lib.ops.embedding.Embedding( 'Encoder.Embedding', 256, CONV_BASE_N_FILTERS, inputs ) embedded = embedded.dimshuffle(0,1,4,2,3) embedded = embedded.reshape(( embedded.shape[0], embedded.shape[1] * embedded.shape[2],
PARAMS_PATH = os.path.join(FOLDER_PREFIX, 'params') if not os.path.exists(PARAMS_PATH): os.makedirs(PARAMS_PATH) SAMPLES_PATH = os.path.join(FOLDER_PREFIX, 'samples') if not os.path.exists(SAMPLES_PATH): os.makedirs(SAMPLES_PATH) BEST_PATH = os.path.join(FOLDER_PREFIX, 'best') if not os.path.exists(BEST_PATH): os.makedirs(BEST_PATH) lib.print_model_settings(locals(), path=FOLDER_PREFIX, sys_arg=True) ### Creating computation graph ### def create_wavenet_block(inp, num_dilation_layer, input_dim, output_dim, name =None): assert name is not None layer_out = inp skip_contrib = [] skip_weights = lib.param(name+".parametrized_weights", lib.floatX(numpy.ones((num_dilation_layer,)))) for i in range(num_dilation_layer): layer_out, skip_c = lib.ops.dil_conv_1D( layer_out, output_dim, input_dim if i == 0 else output_dim, 2, dilation = 2**i,