Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ita9naiwa's full-sized avatar

Hyunsung Lee ita9naiwa

View GitHub Profile
@ita9naiwa
ita9naiwa / cifar.py
Created March 9, 2022 10:01
bonus-ce and MAE
'''
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ita9naiwa
ita9naiwa / GATMHA.py
Last active December 11, 2020 11:42
MultiHeadAttention Block of Graph Attention Network(https://arxiv.org/abs/1710.10903)
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))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ita9naiwa
ita9naiwa / logistic_mf.ipynb
Last active June 4, 2019 09:20
logistic matrix factorization
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ita9naiwa
ita9naiwa / reinforce_mp.py
Last active February 21, 2019 12:30
Reinforce algorithm with multiprocesses
# 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