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
#pragma once | |
#include <immintrin.h> | |
#define I32B __m256i | |
#define STORE_I32B(ptrD, ptrS) _mm256_store_si256(ptrD, *ptrS) | |
/** | |
* Copies the content of one 32 byte aligned | |
* 64 byte buffer into another |
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 numpy as np | |
from numba import njit, prange | |
BIT_COUNT_LOOKUP = np.array([bin(i).count('1') for i in range(256)]).astype(np.uint8) | |
@njit(fastmath=True, nopython=True, parallel=True) | |
def fast_tanimoto_matrix(fingerprints, progress): | |
""" | |
Compute a symmetric Tanimoto similarity matrix over a set of fingerprints of size (N, F//8). | |
Where N is the number of fingerprints, and F is the length of the boolean fingerprint. |
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 json | |
import urllib.request | |
from tqdm import tqdm | |
import multiprocessing | |
with urllib.request.urlopen('https://earthview.withgoogle.com/_api/photos.json') as f: | |
slugs = list(map(lambda slug: slug | dict(id=slug['slug'].split('-')[-1]), | |
json.loads(f.read().decode('utf-8')))) |
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
FROM frolvlad/alpine-python3 | |
# Build and install numpy | |
RUN apk add --no-cache \ | |
--virtual=.build-dependencies \ | |
g++ gfortran file binutils \ | |
musl-dev python3-dev cython openblas-dev lapack-dev && \ | |
apk add libstdc++ openblas lapack && \ | |
\ | |
pip install --disable-pip-version-check --no-build-isolation --no-cache-dir numpy==1.18.5 && \ |
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
--- Strings & Numbers --- | |
<String> := <Char> | <Char> <String> | |
<Char> := <Alpha> | <Digit> | <SpecialChar> | |
<Alpha> := "A..Z" | "a..z" | |
<SpecialChar> := "." | "," | ";" | ":" | "'" | " " | "#" | "$" | "?" | |
<Number> := <NumberPart> | <Sign> <NumberPart> | |
<NumberPart> := <IntPart> | <IntPart> "." <DecimalPart> | |
<IntPart> := "0" | <NZDigit> | <NZDigit> <DecimalPart> |
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
# Keep last N weights and one weight every H hours, discard others | |
old_weight_paths = sorted(list(glob(os.path.join(weight_path, 'style_weights-*.h5')))) | |
# Iterate over weights from newest to oldest, discard oldest weights if multiple were saved that hour | |
prev_weight_age = -1 | |
for old_weight_path in reversed(old_weight_paths[:-keep_last_n_weights]): | |
# Age of this weight file in hours | |
weight_age = int((time() - os.path.getmtime(old_weight_path)) // (60 * 60 * keep_weights_every_n_hours)) |
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
class LinearWarmUpAndCosineDecay(tf.keras.optimizers.schedules.LearningRateSchedule): | |
def __init__(self, initial_learning_rate, warmup_steps, total_steps, alpha, name=None): | |
super(LinearWarmUpAndCosineDecay, self).__init__(name=name) | |
self.warmup_steps = warmup_steps | |
self.total_steps = total_steps | |
self.alpha = alpha | |
self.initial_learning_rate = initial_learning_rate | |
self.min_learning_rate = self.initial_learning_rate * self.alpha |
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
\usepackage{listings} | |
\usepackage{textcomp} | |
\usepackage[utf8]{inputenc} | |
\usepackage[TS1,T1]{fontenc} | |
\usepackage[english]{babel} | |
\usepackage{sourcecodepro} | |
\usepackage{scrextend} | |
\addtokomafont{labelinglabel}{\sffamily} | |
\pdfmapfile{=SourceCodePro.map} |
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 numpy as np | |
import tensorflow as tf | |
class LogMetrics(tf.keras.callbacks.Callback): | |
def __init__(self, log_dir, loss, metrics, steps, dataset, training=False): | |
super(LogMetrics, self).__init__() | |
self.log_dir = log_dir | |
self.metrics = metrics | |
self.steps = steps |
NewerOlder