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 top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')): | |
""" Filter a distribution of logits using top-k and/or nucleus (top-p) filtering | |
Args: | |
logits: logits distribution shape (..., vocabulary size) | |
top_k >0: keep only top k tokens with highest probability (top-k filtering). | |
top_p >0.0: keep the top tokens with cumulative probability >= top_p (nucleus filtering). | |
""" | |
top_k = min(top_k, logits.size(-1)) # Safety check | |
if top_k > 0: | |
# Remove all tokens with a probability less than the last token of the top-k |
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
// Uncompressed version of | |
// https://gist.github.com/munificent/b1bcd969063da3e6c298be070a22b604 | |
#include <time.h> // Robert Nystrom | |
#include <stdio.h> // @munificentbob | |
#include <stdlib.h> // for Ginny | |
#include <stdbool.h> // 2008-2019 | |
const int HEIGHT = 40; | |
const int WIDTH = 80; |
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
/.idea/ | |
/cmake-build-debug/ | |
/dungeon |
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
#!/usr/bin/env bash | |
# First download cudnn to a directory /tmp/binaries. | |
# The filename should be cudnn-9.2-linux-x64-v7.1.tgz | |
set -e | |
# Install driver | |
sudo add-apt-repository ppa:graphics-drivers/ppa | |
sudo apt-get update |
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 z3 import * | |
# find the (distinct) integers in 0..9 that make this equation work: | |
# | |
# SEND | |
# + MORE | |
# ------ | |
# MONEY | |
S = Int('S') |
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 sys import version_info | |
assert version_info.major == 3 and version_info.minor >= 3, \ | |
'requires PEP 362; Python 3.3 or later; python.org/dev/peps/pep-0362/' | |
from inspect import signature | |
class memoise(dict): | |
def __init__(self, func): | |
self.func, self.signature = func, signature(func) | |
def __missing__(self, key): | |
args, kwargs = key |
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
for i in {1..100}; do | |
filepath=$(printf "http://caliban.mpipz.mpg.de/haeckel/kunstformen/Tafel_%03d_300.jpg" $i) | |
wget $filepath; | |
done |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.