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
#!/usr/bin/env python | |
# -*- coding:UTF-8 -*- | |
import torch | |
import torch.nn as nn | |
import torch.nn.init as init | |
def weight_init(m): | |
''' |
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 draw_line(vis, step, lines, names): | |
# draw multiple lines in one panel. | |
""" | |
:param vis: the object of the visdom.Visdom | |
:param step: the step of the line | |
:param lines: the lines tuple, (line1, line2, ...) | |
:param names: the names tuple, (name1, name2, ...) | |
:return: None | |
""" |
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.autograd as autograd | |
from torch.nn.utils.rnn import pad_packed_sequence, pack_padded_sequence | |
# Create some fake sorted data with 0 pad | |
data = autograd.Variable(torch.LongTensor([[3, 4, 5, 1, 9], | |
[3, 1, 3, 4, 0], | |
[5, 3, 6, 0, 0]])) |