예제 #1
0
    def run(self, tuple_in):
        shape, midi_in = tuple_in
        pianorolls = self.decoder.encode_midi_to_pianoroll(midi_in, shape)
        # fill in the silences
        masks = lib_sampling.CompletionMasker()(pianorolls)
        gibbs = self.make_sampler("gibbs",
                                  masker=lib_sampling.BernoulliMasker(),
                                  sampler=self.make_sampler(
                                      "independent",
                                      temperature=FLAGS.temperature),
                                  schedule=lib_sampling.YaoSchedule())

        with self.logger.section("context"):
            context = np.array([
                lib_mask.apply_mask(pianoroll, mask)
                for pianoroll, mask in zip(pianorolls, masks)
            ])
            self.logger.log(pianorolls=context,
                            masks=masks,
                            predictions=context)
        pianorolls = gibbs(pianorolls, masks)
        with self.logger.section("result"):
            self.logger.log(pianorolls=pianorolls,
                            masks=masks,
                            predictions=pianorolls)
        return pianorolls
예제 #2
0
    def run(self, shape):
        init_sampler = self.make_sampler("bach", temperature=FLAGS.temperature)
        pianorolls, masks = self.blank_slate(shape)
        pianorolls = init_sampler(pianorolls, masks)

        masks = lib_sampling.HarmonizationMasker()(shape)

        gibbs = self.make_sampler("gibbs",
                                  masker=lib_sampling.BernoulliMasker(),
                                  sampler=self.make_sampler(
                                      "independent",
                                      temperature=FLAGS.temperature),
                                  schedule=lib_sampling.YaoSchedule())

        with self.logger.section("context"):
            context = np.array([
                lib_mask.apply_mask(pianoroll, mask)
                for pianoroll, mask in zip(pianorolls, masks)
            ])
            self.logger.log(pianorolls=context,
                            masks=masks,
                            predictions=context)
        pianorolls = gibbs(pianorolls, masks)
        with self.logger.section("result"):
            self.logger.log(pianorolls=pianorolls,
                            masks=masks,
                            predictions=pianorolls)

        return pianorolls
예제 #3
0
    def run(self, shape):
        init_sampler = self.make_sampler("bach", temperature=FLAGS.temperature)
        pianorolls, masks = self.blank_slate(shape)
        pianorolls = init_sampler(pianorolls, masks)

        sampler = self.make_sampler("gibbs",
                                    masker=lib_sampling.BernoulliMasker(),
                                    sampler=self.make_sampler(
                                        "independent",
                                        temperature=FLAGS.temperature),
                                    schedule=lib_sampling.YaoSchedule())

        for i in range(shape[-1]):
            masks = lib_sampling.InstrumentMasker(instrument=i)(shape)
            with self.logger.section("context"):
                context = np.array([
                    lib_mask.apply_mask(pianoroll, mask)
                    for pianoroll, mask in zip(pianorolls, masks)
                ])
                self.logger.log(pianorolls=context,
                                masks=masks,
                                predictions=context)
            pianorolls = sampler(pianorolls, masks)

        return pianorolls
예제 #4
0
 def run(self, shape):
     pianorolls, masks = self.blank_slate(shape)
     sampler = self.make_sampler("gibbs",
                                 masker=lib_sampling.BernoulliMasker(),
                                 sampler=self.make_sampler(
                                     "independent",
                                     temperature=FLAGS.temperature),
                                 schedule=lib_sampling.YaoSchedule())
     pianorolls = sampler(pianorolls, masks)
     return pianorolls
예제 #5
0
 def run(self, shape):
     pianorolls, masks = self.blank_slate(shape)
     sampler = self.make_sampler(
         "gibbs",
         masker=lib_sampling.BernoulliMasker(),
         sampler=self.make_sampler(
             "ancestral",
             selector=lib_sampling.OrderlessSelector(),
             temperature=FLAGS.temperature),
         schedule=lib_sampling.YaoSchedule())
     pianorolls = sampler(pianorolls, masks)
     return pianorolls
예제 #6
0
 def run(self, shape):
     # optionally start with bach samples
     init_sampler = self.make_sampler("bach", temperature=FLAGS.temperature)
     pianorolls, masks = self.blank_slate(shape)
     pianorolls = init_sampler(pianorolls, masks)
     desired_length = 4 * shape[1]
     sampler = self.make_sampler("upsampling",
                                 desired_length=desired_length,
                                 sampler=self.make_sampler(
                                     "gibbs",
                                     masker=lib_sampling.BernoulliMasker(),
                                     sampler=self.make_sampler(
                                         "independent",
                                         temperature=FLAGS.temperature),
                                     schedule=lib_sampling.YaoSchedule()))
     return sampler(pianorolls, masks)
예제 #7
0
    def run(self, shape):
        # start with an empty pianoroll of length 1, then repeatedly upsample
        initial_shape = list(shape)
        desired_length = shape[1]
        initial_shape[1] = 1
        initial_shape = tuple(shape)

        pianorolls, masks = self.blank_slate(initial_shape)

        sampler = self.make_sampler("upsampling",
                                    desired_length=desired_length,
                                    sampler=self.make_sampler(
                                        "gibbs",
                                        masker=lib_sampling.BernoulliMasker(),
                                        sampler=self.make_sampler(
                                            "independent",
                                            temperature=FLAGS.temperature),
                                        schedule=lib_sampling.YaoSchedule()))

        return sampler(pianorolls, masks)
예제 #8
0
    def run(self, tuple_in):
        shape, midi_in = tuple_in
        mroll = self.load_midi_melody(midi_in)
        pianorolls = self.make_pianoroll_from_melody_roll(mroll, shape)
        masks = lib_sampling.HarmonizationMasker()(pianorolls.shape)
        gibbs = self.make_sampler("gibbs",
                                  masker=lib_sampling.BernoulliMasker(),
                                  sampler=self.make_sampler(
                                      "independent",
                                      temperature=FLAGS.temperature),
                                  schedule=lib_sampling.YaoSchedule())

        with self.logger.section("context"):
            context = np.array([
                lib_mask.apply_mask(pianoroll, mask)
                for pianoroll, mask in zip(pianorolls, masks)
            ])
            self.logger.log(pianorolls=context,
                            masks=masks,
                            predictions=context)
        pianorolls = gibbs(pianorolls, masks)

        return pianorolls