Skip to content

Instantly share code, notes, and snippets.

View liguge's full-sized avatar
😆
On working

Chao He liguge

😆
On working
  • Beijing Jiaotong University
  • Beijing, China
View GitHub Profile
@hazdzz
hazdzz / casualconv.py
Created May 2, 2021 05:31
Dilated Causal Convolution
import torch
import torch.nn as nn
import torch.nn.functional as F
class CausalConv1d(nn.Conv1d):
def __init__(self, in_channels, out_channels, kernel_size, stride=1, enable_padding=False, dilation=1, groups=1, bias=True):
if enable_padding == True:
self.__padding = (kernel_size - 1) * dilation
else:
self.__padding = 0
@yusuke0519
yusuke0519 / central_mean_diescrepancy.py
Created April 12, 2019 03:25
PyTorch implementation of central mean discrepancy (https://arxiv.org/abs/1702.08811)
# # -*- coding: utf-8 -*-
import itertools
from torch.utils import data
def l2diff(x1, x2):
"""
standard euclidean norm
"""
return ((x1-x2)**2).sum().sqrt()
@jeasinema
jeasinema / weight_init.py
Last active May 25, 2023 09:32
A simple script for parameter initialization for PyTorch
#!/usr/bin/env python
# -*- coding:UTF-8 -*-
import torch
import torch.nn as nn
import torch.nn.init as init
def weight_init(m):
'''