Code
https://gist.github.com/victor-shepardson/5b3d3087dc2b4817b9bffdb8e87a57c4
Setup
I'm using Ubuntu 16.04 with a GTX 1060
def typical_top_k_filtering(logits, top_k=0, top_p=0.0, temperature=1.0, min_tokens_to_keep=1, filter_value=-1E12): | |
""" Filter a distribution of logits using typicality, with optional top-k and/or nucleus (top-p) filtering | |
Meister et. al. https://arxiv.org/abs/2202.00666 | |
Args: | |
logits: logits distribution shape (..., vocabulary size) | |
top_k >0: keep top k tokens with highest prob (top-k filtering). | |
top_p >0.0: keep the top p tokens which compose cumulative probability mass top_p (nucleus filtering). | |
min_tokens_to_keep >=1: always keep at least this many tokens through the top_p / nucleus sampling | |
""" | |
# https://arxiv.org/abs/2202.00666 |
{ | |
"seconds_per_quarter": 0.5, | |
"parts_names": [ | |
"Soprano", | |
"Alto", | |
"Tenor", | |
"Bass" | |
], | |
"parts_cumulative_times": [ | |
[ |
import numpy as np | |
# make a minibatch of time, batch, features | |
# time length 7 | |
# batch size 2 | |
# feature dimension 4: | |
# 1:4, 10:14, 20:24, 30:34, etc for first minibatch element | |
# 5:8, 15:18, etc second minibatch el | |
n_features = 4 | |
n_timesteps = 7 |
#!/usr/bin/env python3 | |
""" | |
To use: | |
1. install/set-up the google cloud api and dependencies listed on https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/texttospeech/cloud-client | |
2. install pandoc and pypandoc, also tqdm | |
3. create and download a service_account.json ("Service account key") from https://console.cloud.google.com/apis/credentials | |
4. run GOOGLE_APPLICATION_CREDENTIALS=service_account.json python make_audiobook.py book_name.epub | |
""" | |
import re | |
import sys |
#!/usr/bin/env python3 | |
""" | |
To use: | |
1. install/set-up the google cloud api and dependencies listed on https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/texttospeech/cloud-client | |
2. install pandoc and pypandoc, also tqdm | |
3. create and download a service_account.json ("Service account key") from https://console.cloud.google.com/apis/credentials | |
4. run GOOGLE_APPLICATION_CREDENTIALS=service_account.json python make_audiobook.py book_name.epub | |
""" | |
import re | |
import sys |
Some planets may orbit a supermassive black hole instead of a star | |
This is almost certainly not what Denisovans looked like | |
UN climate summit: Scientists' messages to world leaders | |
A hat that zaps the scalp with electricity helps reverse male balding | |
Man sees the world in miniature after a stroke damages his brain | |
Do dads matter? Anna Machin on the fascinating science of fatherhood | |
People like the idea of a carbon tax - if the money is put to good use | |
Climate change will boost risk of extreme flooding in northern Europe | |
Fast swimming fish robot could perform underwater surveillance | |
Ad Astra: Pirates and space monkeys can't save dull space psychodrama |
https://gist.github.com/victor-shepardson/5b3d3087dc2b4817b9bffdb8e87a57c4
I'm using Ubuntu 16.04 with a GTX 1060
import jax | |
import jax.numpy as np | |
from jax import grad, jit | |
from jax.scipy.special import logsumexp | |
def dadashi_fig2d(): | |
""" Figure 2 d) of | |
''The Value Function Polytope in Reinforcement Learning'' | |
by Dadashi et al. (2019) https://arxiv.org/abs/1901.11524 |