This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.multiprocessing as multiprocessing | |
import time | |
DEVICE = torch.device("cuda") | |
class Model1(nn.Module): | |
def __init__(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gaussian_distribution(y, mu, sigma): | |
## Prepare the input to be transformed into a gaussian distribution | |
y = y.unsqueeze(1) | |
y = y.expand(-1, GAUSSIANS, LATENT_VEC) | |
res = torch.exp((-0.5 * ((y - mu) / sigma) ** 2) / TEMPERATURE) | |
result = MDN_CONST * res / sigma | |
return result | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from torch.autograd import Variable | |
import torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
# length of board | |
L = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
import multiprocessing.pool | |
import torch | |
class NoDaemonProcess(multiprocessing.Process): | |
# make 'daemon' attribute always return False | |
def _get_daemon(self): | |
return False | |
def _set_daemon(self, value): |