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 neg_squared_euc_dists_1(X): | |
sum_X = np.sum(np.square(X), 1) | |
D = np.add(np.add(-2 * np.dot(X, X.T), sum_X).T, sum_X) | |
return -D | |
def neg_squared_euc_dists_2(X): | |
sum_X = np.sum(np.square(X), 1) | |
D = np.add(np.add(-2 * np.dot(X, X.T), sum_X).T, -sum_X) | |
return -D |
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
import pylab as plt | |
import sys | |
import numpy as np | |
from PIL import Image | |
import torch | |
from torch import nn as nn | |
def plot_tch(inp): | |
r = np.clip(inp[0].permute(1, 2, 0).detach().numpy(), 0, 255).astype( |