A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
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) |
""" 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 |
# 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 |