Skip to content

Instantly share code, notes, and snippets.

View JoeHEZHAO's full-sized avatar
🎯
Focusing

hz JoeHEZHAO

🎯
Focusing
View GitHub Profile
@yangkky
yangkky / masked_batch_norm.py
Last active December 10, 2022 20:24
Masked 1D batchnorm in PyTorch.
import torch
import torch.nn as nn
from torch.nn import init
class MaskedBatchNorm1d(nn.Module):
""" A masked version of nn.BatchNorm1d. Only tested for 3D inputs.
Args:
num_features: :math:`C` from an expected input of size
@stober
stober / softmax.py
Created March 1, 2012 03:05
Softmax in Python
#! /usr/bin/env python
"""
Author: Jeremy M. Stober
Program: SOFTMAX.PY
Date: Wednesday, February 29 2012
Description: Simple softmax function.
"""
import numpy as np
npa = np.array