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
''' | |
Train CIFAR10 with PyTorch. | |
based on https://github.com/kuangliu/pytorch-cifar | |
''' | |
import torch | |
import torch.nn as nn | |
import torch.optim as optim | |
import torch.nn.functional as F | |
import torch.backends.cudnn as cudnn |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
class GATMHA(nn.Module): | |
def __init__(self, hidden_size, n_heads, lralpha=0.2): | |
super(GATMHA, self).__init__() | |
self.W = nn.Linear(hidden_size, hidden_size, bias=True) | |
self.Q = nn.Linear(hidden_size, hidden_size, bias=True) | |
self.a = nn.Parameter(torch.FloatTensor(n_heads, 2 * (hidden_size // n_heads))) | |
self.lralpha = lralpha | |
self.n_heads = n_heads | |
self.n_hidden_per_head = hidden_size // n_heads | |
nn.init.uniform_(self.W.weight, -1 / np.sqrt(hidden_size), 1 / np.sqrt(hidden_size)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# mainly brought from https://github.com/pytorch/examples/blob/master/reinforcement_learning/reinforce.py | |
import gym | |
import numpy as np | |
import torch | |
from torch import nn | |
from torch import optim | |
import torch.nn.functional as F | |
from torch.distributions import Categorical | |
import torch.multiprocessing as mp |