Skip to content

Instantly share code, notes, and snippets.

import torch
import torch.nn as nn
import torch.nn.functional as F
# helpers
def make_unit_length(x, epsilon=1e-6):
norm = x.norm(p=2, dim=-1, keepdim=True)
return x.div(norm + epsilon)
@saliksyed
saliksyed / autoencoder.py
Created November 18, 2015 03:30
Tensorflow Auto-Encoder Implementation
""" Deep Auto-Encoder implementation
An auto-encoder works as follows:
Data of dimension k is reduced to a lower dimension j using a matrix multiplication:
softmax(W*x + b) = x'
where W is matrix from R^k --> R^j
A reconstruction matrix W' maps back from R^j --> R^k
@sloria
sloria / bobp-python.md
Last active April 20, 2024 13:02
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@compor
compor / bash_patch_between_files.sh
Created February 25, 2013 15:09
create and apply a patch between files in two directories
# produces a patch between the files in the 2 dirs
# -c : special context for output
# -r : directory recursively
# -B : ignore blanks
diff -crB before_dir after_dir > foo.patch
# if you want to patch before_dir now