Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE | |
# python image_diff.py --first images/original_01.png --second images/modified_01.png | |
# import the necessary packages | |
from skimage.measure import compare_ssim | |
import argparse | |
import imutils | |
import cv2 | |
# construct the argument parse and parse the arguments |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tf_pca(x): | |
''' | |
Compute PCA on the bottom two dimensions of x, | |
eg assuming dims = [..., observations, features] | |
''' | |
# Center | |
x -= tf.reduce_mean(x, -2, keepdims=True) | |
# Currently, the GPU implementation of SVD is awful. | |
# It is slower than moving data back to CPU to SVD there |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on https://github.com/pytorch/pytorch/pull/3740 | |
import torch | |
import math | |
class AdamW(torch.optim.Optimizer): | |
"""Implements AdamW algorithm. | |
It has been proposed in `Fixing Weight Decay Regularization in Adam`_. | |
Arguments: |
OlderNewer