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 os | |
import argparse | |
from pathlib import Path | |
import warnings | |
import torch | |
import torch.nn as nn | |
import torchvision.datasets as datasets | |
import torch.utils.data as data | |
import torchvision.transforms as transforms |
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
from contextlib import contextmanager | |
import matplotlib.pyplot as plt | |
import base64 | |
from io import BytesIO | |
from IPython.display import HTML, display | |
@contextmanager | |
def dp(width=600, dpi=300): | |
def display_figure(): | |
# Save the current figure as a PNG image in memory |
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 os | |
import argparse | |
from pathlib import Path | |
import warnings | |
import torch | |
import torchvision | |
import torch.nn as nn | |
import torchvision.datasets as datasets | |
import torch.utils.data as data |
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
# coding: utf-8 | |
from sklearn.cluster import AffinityPropagation | |
from sklearn import metrics | |
from sklearn.datasets.samples_generator import make_blobs | |
import scipy | |
import scipy.stats | |
import numpy as np | |
from collections import Counter |
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 scipy | |
import numpy as np | |
from collections import Counter | |
# Kullback–Leibler divergence | |
# https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence | |
# http://scipy.github.io/devdocs/generated/scipy.stats.entropy.html | |
def kl(p, q): | |
# compute common elements |
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
<?php | |
error_reporting(E_ERROR | E_PARSE); | |
function get_content($body) { | |
$doc = new DOMDocument; | |
$doc->preserveWhiteSpace = false; | |
$content = ""; | |
if ($doc->loadXML($body)) { | |
foreach ($doc->getElementsByTagName("body") as $t) { | |
foreach ($t->getElementsByTagName("paragraph") as $p) { | |
$content = $content . '<p>' . $p->textContent . '</p>'; |
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
<?php | |
error_reporting(E_ERROR | E_PARSE); | |
function get_content($body) { | |
$doc = new DOMDocument; | |
$doc->preserveWhiteSpace = false; | |
if (!$doc->loadXML($body)) | |
return $body; | |
$content = ""; | |
foreach ($doc->getElementsByTagName("body") as $t) { | |
foreach ($t->getElementsByTagName("paragraph") as $p) { |