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 init_gru(cell, gain=1): | |
cell.reset_parameters() | |
# orthogonal initialization of recurrent weights | |
for _, hh, _, _ in cell.all_weights: | |
for i in range(0, hh.size(0), cell.hidden_size): | |
I.orthogonal(hh[i:i + cell.hidden_size], gain=gain) | |
def init_lstm(cell, gain=1): |
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 np | |
from torch.utils.data import Dataset | |
class GenHelper(Dataset): | |
def __init__(self, mother, length, mapping): | |
# here is a mapping from this index to the mother ds index | |
self.mapping=mapping | |
self.length=length | |
self.mother=mother |
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
# Now available here: https://github.com/y0ast/pytorch-snippets/tree/main/minimal_cifar |
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
%matplotlib widget # need to install ipympl | |
import numpy as np | |
from matplotlib.lines import Line2D | |
from matplotlib.artist import Artist | |
import matplotlib | |
import matplotlib.pyplot as plt | |
from matplotlib.patches import Polygon | |
import numpy as np |