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 = 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
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
def run(self, tuple_in, temperature): shape, midi_in, prime_midi_melody_fpath = tuple_in mroll = self.load_midi_melody(prime_midi_melody_fpath, 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=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
def run(self, pianorolls, temperature): # fill in the silences masks = lib_sampling.CompletionMasker()(pianorolls) gibbs = self.make_sampler("gibbs", masker=lib_sampling.BernoulliMasker(), sampler=self.make_sampler( "independent", temperature=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
def run(self, shape, temperature): init_sampler = lib_sampling.BachSampler(wmodel=self.wmodel, temperature=temperature) pianorolls, masks = self.blank_slate(shape) pianorolls = init_sampler(pianorolls, masks) masks = lib_sampling.TransitionMasker()(shape) gibbs = self.make_sampler("gibbs", masker=lib_sampling.BernoulliMasker(), sampler=self.make_sampler( "independent", temperature=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