if path_model == MODEL_vae2_1:
        state_dict = torch.load(os.path.join(path_model, 'model_state.pth'),map_location=torch.device('cpu'))
        model = autoencoder
        print('Loading Passed')
    else:
        model = WitnessComplexAutoencoder(autoencoder)
        state_dict = torch.load(os.path.join(path_model, 'model_state.pth'),map_location=torch.device('cpu'))

        state_dict2 = torch.load(os.path.join(os.path.join(path_norm2,exp_norm2), 'model_state.pth'))
        if 'latent' not in state_dict:
            state_dict['latent_norm'] = state_dict2['latent_norm'] * 0.1

        print('passed')

    model.load_state_dict(state_dict)
    model.eval()

    z = model.encode(images.float())
    debugging = True

    np.save('/Users/simons/PycharmProjects/MT-VAEs-TDA/src/datasets/simulated/xy_trans_l_newpers/latents_wae.np', z.detach().numpy())



    # plot_2Dscatter(z.detach().numpy(), labels, path_to_save=os.path.join(path_save, 'pos_{}.pdf'.format(
    #     time.strftime("%Y%m%d-%H%M%S"))), title=None, show=True, palette = 'custom')


Пример #2
0
        state_dict = torch.load(os.path.join(path_exp, 'model_state.pth'),
                                map_location=torch.device('cpu'))
        state_dict2 = torch.load(
            os.path.join(os.path.join(path_norm2, exp_norm2), 'model_state.pth'))
        if 'latent' not in state_dict:
            state_dict['latent_norm'] = state_dict2['latent_norm']*0.1

        print('passed')


        model.load_state_dict(state_dict)
        model.eval()

        dataset = MNIST_offline()
        data, labels = dataset.sample(train = False)

        z = model.encode(torch.Tensor(data).float())

        np.save(os.path.join(path_exp,'wae_path_stdiso'),z.detach().numpy())
        np.save(os.path.join(path_exp, 'labelswae_path_stdiso'), labels)

        #
        # df = pd.DataFrame(z)
        # df['labels'] = labels
        # df.to_csv(os.path.join(path_exp, '{}_latents.csv'.format('final')), index=False)


        # plot_2Dscatter(z.detach().numpy(), labels, path_to_save=os.path.join(
        #     path_exp, '{}_latent_visualization.pdf'.format('final')), title=None, show=False,
        #                palette='custom2')