Exemplo n.º 1
0
        code_ndim=2,
        # hparam
        trainable_gen=['generator'],
        D_lr=1e-3,
        G_lr=5e-4,  # change to 1e-4 when finetuning
        G_k=5,
        D_boost=0,
        G_clipnorm=None,  # 1.0,
        # traini
        batch_size=32,
        continued=False,
        overwrite_workdir=True,
        iterations=20000,
        workdir='./temp/DCRNN_RhythmGAN/'
    )
    model = DCRNN(hparam)
    model.build()
    # coder = NoteDurationCoder(normalize_key='C5', first_voice=False)
    coder = MultiHotCoder(normalize_key='C5', only_major=True)

    if hparam.code_dim == 3:
        def sample(batch_size):
            code_s = np.random.uniform(-1., +1.,
                                       size=(batch_size,
                                             hparam.code_dim))
            code_e = np.random.uniform(-1., +1.,
                                       size=(batch_size,
                                             hparam.code_dim))
            res = np.zeros((batch_size,
                            hparam.timesteps,
                            hparam.code_dim))
Exemplo n.º 2
0
        show_grad=False,
        show_input=True,
        # hparam
        trainable_gen=['generator'],
        D_lr=1e-3,
        G_lr=5e-4,  # change to 1e-4 when finetuning
        G_k=5,
        D_boost=0,
        G_clipnorm=None,  # 1.0,
        # traini
        batch_size=32,
        continued=False,
        overwrite_workdir=True,
        iterations=10000,
        workdir='./temp/Fillblank/')
    model = DCRNN(hparam)
    model.build()
    # coder = NoteDurationCoder(normalize_key='C5', first_voice=False)
    coder = MultiHotCoder(normalize_key='C5', with_velocity=True)

    try:
        data = np.load('temp/easy.npz')['data']
    except:
        data = np.array(
            map_dir(lambda fn: coder.encode(ms.converter.parse(fn)),
                    './datasets/easymusicnotes/'))
        np.savez('temp/easy.npz', data=data)

    print(len(data), map(lambda x: len(x), data))
    data = filter(lambda x: len(x) > 0 and x.shape[1] > hparam.timesteps, data)
    # import matplotlib.pyplot as plt
Exemplo n.º 3
0
        cond_dim=12,
        # hparam
        trainable_gen=['generator'],
        D_lr=1e-3,
        G_lr=8e-4,  # change to 1e-4 when finetuning
        G_k=2,
        D_boost=0,
        G_clipnorm=None,  # 1.0,
        # traini
        batch_size=32,
        continued=False,
        overwrite_workdir=True,
        iterations=40000,
        workdir='./temp/DCRNN_cond/'
    )
    model = DCRNN(hparam)
    model.build()
    # coder = NoteDurationCoder(normalize_key='C5', first_voice=False)
    # coder = MultiHotCoder(normalize_key='C5', only_major=True)
    coder = MultiHotCoder(# normalize_key='C5',
                          with_velocity=True,
                          # only_major=True,
                          length_limit=np.inf)

    try:
        # data = np.load('temp/easy.npz')
        # raise Exception
        data = np.load('temp/piano-midi.npz')
        voi, vel = data['voice'], data['velocity']
        # data = (voi*vel)/127.
        data = voi