Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

陈诚 Cheneng

🎯
Focusing
Block or report user

Report or block Cheneng

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Cheneng
Cheneng / pp_tutorial.py
Created Mar 13, 2018
The tutorial of the pack_padded_sequence and pad_packed_sequence in PyTorch.
View pp_tutorial.py
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]]))
@Cheneng
Cheneng / visdom_multiple_line.py
Created Jun 21, 2018
draw multiple lines in visdom
View visdom_multiple_line.py
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
"""
@Cheneng
Cheneng / weight_init.py
Created Jul 16, 2019 — forked from jeasinema/weight_init.py
A simple script for parameter initialization for PyTorch
View weight_init.py
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
import torch
import torch.nn as nn
import torch.nn.init as init
def weight_init(m):
'''
You can’t perform that action at this time.