def __init__(self):
        super(VAERNN, self).__init__()

        self.z_size = 32
        self.kl_tolerance = 0.5

        self.vae = VAE()
        self.rnn = RNN()

        self.vae.train()
        self.rnn.train()
        self.init_()

        self.is_cuda = False
    def __init__(self):
        super(VAERNN, self).__init__()

        self.z_size = 32
        self.kl_tolerance = 0.5

        self.vae = VAE()
        self.rnn = RNN()
        self.vae.load_state_dict(
            torch.load(vae_model_path,
                       map_location=lambda storage, loc: storage))
        self.rnn.load_state_dict(
            torch.load(rnn_model_path,
                       map_location=lambda storage, loc: storage))
        self.vae.train()
        self.rnn.train()
        self.init_()

        self.is_cuda = False
Ejemplo n.º 3
0
import torch.multiprocessing as mp
import torch.optim as optim

from this_util import *
from vae import VAE
from rnn_me import RNN
from policy import Policy

vae_model = VAE()
vae_model.load_state_dict(
    torch.load(vae_model_path, map_location=lambda storage, loc: storage)
)  #, map_location=lambda storage, loc: storage)

vae_model.eval()

rnn_model = RNN()
rnn_model.load_state_dict(
    torch.load(rnn_model_path, map_location=lambda storage, loc: storage))
rnn_model.eval()


def wow(state, h, policy, vae_model, rnn_model):
    state = tensor_state(state)
    z = vae_model(state)
    h = h.squeeze(0)
    z_h = torch.cat((z, h), dim=1)
    a = policy(z_h)

    one = one_hot(a)
    one = torch.from_numpy(one)
    one = one.unsqueeze(0)