def _test_sample_vae():
    train_dataset = LyricsRawDataset(os.path.join('local_data', 'data'), TRAIN_SET, genre=Genre.Rock)

    vae = SentenceVAE(
        vocab_size=train_dataset.vocab_size,
        sos_idx=train_dataset.sos_idx,
        eos_idx=train_dataset.eos_idx,
        pad_idx=train_dataset.pad_idx,
        unk_idx=train_dataset.unk_idx,
        max_sequence_length=50,
        embedding_size=300,
        rnn_type='gru',
        hidden_dim=64,
        latent_size=32).cuda()
    # vae: SentenceVAE

    datamanager = DataManager("./local_data/results/2019-09-26_19.18.29")

    loaded = datamanager.load_python_obj("models/model_best")

    state_dict = 0
    for state_dict in loaded.values():
        state_dict = state_dict

    vae.load_state_dict(state_dict)

    vae.eval()

    y = vae.sample()

    for sen in y:
        string = ""
        for num in sen:
            string += (train_dataset.i2w[str(num.item())])

        print(string)
Exemple #2
0
 def setup(self, data_manager: DataManager, set_name: str) -> List[Song]:
     x: List[Song] = data_manager.load_python_obj(f'song_lyrics.{set_name}')
     return x
Exemple #3
0
 def setup(self, data_manager: DataManager, set_name: str):
     x = data_manager.load_python_obj(f'song_lyrics.{set_name}')
     x: List[Song]
     return [song for song in x if self.genre == song.genre]
Exemple #4
0
 def setup(self, data_manager: DataManager, set_name: str):
     return data_manager.load_python_obj(f'song_lyrics.{set_name}')