Skip to content

Instantly share code, notes, and snippets.

View hazdzz's full-sized avatar

Chieh Chang hazdzz

  • National Central University
  • Taiwan
View GitHub Profile
from torch import Tensor
from typing import Callable, List, Optional, Tuple
import math
import warnings
import torch
import torch.nn as nn
import torch.nn.functional as F
class CSigmoid(nn.Module):
def forward(self, input: Tensor) -> Tensor:
@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