Skip to content

Instantly share code, notes, and snippets.

View xrrain's full-sized avatar
🎯
Focusing

xrrain xrrain

🎯
Focusing
  • ShanghaiTech
  • Shanghai, China
View GitHub Profile
@xrrain
xrrain / tied_linear.py
Created July 20, 2021 02:37 — forked from InnovArul/tied_linear.py
tied linear layer experiment
import torch, torch.nn as nn, torch.nn.functional as F
import numpy as np
import torch.optim as optim
# tied autoencoder using off the shelf nn modules
class TiedAutoEncoderOffTheShelf(nn.Module):
def __init__(self, inp, out, weight):
super().__init__()
self.encoder = nn.Linear(inp, out, bias=False)
self.decoder = nn.Linear(out, inp, bias=False)