I hereby claim:
- I am harpone on github.
- I am harpone (https://keybase.io/harpone) on keybase.
- I have a public key ASDFQqiM9-Yg0wVF3nsnOaVSan8jKCAgtTLccHHts8RhaQo
To claim this, I am signing this object:
""" | |
MIT License | |
knn, kl_div, entropy Copyright (c) 2017 Heikki Arponen | |
""" | |
import torch | |
def knn(x, y, k=3, last_only=False, discard_nearest=True): |
import tensorflow as tf | |
from tensorflow.python.framework import ops | |
import numpy as np | |
# Define custom py_func which takes also a grad op as argument: | |
def py_func(func, inp, Tout, stateful=True, name=None, grad=None): | |
# Need to generate a unique name to avoid duplicates: | |
rnd_name = 'PyFuncGrad' + str(np.random.randint(0, 1E+8)) | |
I hereby claim:
To claim this, I am signing this object:
def forward_sequential(h, xs, U, W, nu, theta): | |
"""Forward pass through the network sequentially over input `xs` of any length. | |
NOTE: has no batch dimension. To be batched with `vmap`. | |
Args: | |
h (torch.tensor): shape [D_h, ]; previous state | |
xs (torch.tensor): shape [T, D_x]; input sequence | |
U (torch.tensor): Parameter matrix of shape [D_h, D_x] | |
W (torch.tensor): Parameter matrix of shape [D_h, D_x] | |
xi (torch.tensor): Parameter vector of shape [D_h, ] |
# PARALLEL: | |
from contractpool import ContractPool # imaginary 'contractpool' library, similar to python's `multiprocessing` | |
W = parameter(M, N) | |
def forward(x_: float32[N]) -> float32: | |
# matrix-vector multiplication: | |
zs = float32[M] # let's imagine we have a float32 dtype in Vyper | |
with ContractPool(dot, M) as p: | |
p.map(W, x_, out=zs) # launches M subcontracts asynchronously, each subcontract writes values to zs |
# SERIAL: | |
W = parameter(M, N) | |
def forward(x_: float32[N]) -> float32: | |
# matrix-vector multiplication: | |
zs = float32[M] # let's imagine we have a float32 dtype in Vyper | |
for i, W_row in enumerate(W): | |
zs[i] = dot(W_row, x_) # 'dot' is an external smart contract | |
# summation: |
from itertools import islice | |
import os | |
import torch | |
from torch.utils.data import DataLoader | |
from torchvision import transforms | |
import numpy as np | |
import torch_xla.distributed.parallel_loader as pl | |
import torch_xla.core.xla_model as xm | |
import torch_xla.distributed.xla_multiprocessing as xmp |
Long-lasting COVID-19 - | |
Consensus statement of the expert group appointed by STM on 31 December 2021 | |
VN / 20672/2021 | |
DRAFT 7.1.2022 | |
class GCSDataset(Dataset): | |
"""Generic PyTorch dataset for GCS. Streams data from GCS and (optionally) caches to local disk. | |
""" | |
def __init__(self, | |
bucketname=None, | |
path_list=None, # TODO: list bucket/path contents if None | |
target_list=None, | |
transform=None, |
from itertools import islice | |
from munch import Munch | |
import sys, os | |
from torch.utils.data import DataLoader | |
from torchvision import transforms | |
import time | |
import webdataset as wds | |
sys.path.append(os.getcwd()) |