python_code stringlengths 0 1.02M | repo_name stringlengths 9 48 | file_path stringlengths 5 114 |
|---|---|---|
import torch
import torch.nn.functional as F
from torch import nn
from torch.optim import Adam
from einops import rearrange, repeat
import sidechainnet as scn
from egnn_pytorch.egnn_pytorch import EGNN_Network
torch.set_default_dtype(torch.float64)
BATCH_SIZE = 1
GRADIENT_ACCUMULATE_EVERY = 16
def cycle(loader, le... | egnn-pytorch-main | denoise_sparse.py |
from setuptools import setup, find_packages
setup(
name = 'egnn-pytorch',
packages = find_packages(),
version = '0.2.6',
license='MIT',
description = 'E(n)-Equivariant Graph Neural Network - Pytorch',
author = 'Phil Wang, Eric Alcaide',
author_email = 'lucidrains@gmail.com',
url = 'https://github.com/l... | egnn-pytorch-main | setup.py |
import torch
from torch import nn, einsum, broadcast_tensors
import torch.nn.functional as F
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
# helper functions
def exists(val):
return val is not None
def safe_div(num, den, eps = 1e-8):
res = num.div(den.clamp(min = eps))
r... | egnn-pytorch-main | egnn_pytorch/egnn_pytorch.py |
from egnn_pytorch.egnn_pytorch import EGNN, EGNN_Network
from egnn_pytorch.egnn_pytorch_geometric import EGNN_Sparse, EGNN_Sparse_Network
| egnn-pytorch-main | egnn_pytorch/__init__.py |
import torch
from torch import sin, cos, atan2, acos
def rot_z(gamma):
return torch.tensor([
[cos(gamma), -sin(gamma), 0],
[sin(gamma), cos(gamma), 0],
[0, 0, 1]
], dtype=gamma.dtype)
def rot_y(beta):
return torch.tensor([
[cos(beta), 0, sin(beta)],
[0, 1, 0],
... | egnn-pytorch-main | egnn_pytorch/utils.py |
import torch
from torch import nn, einsum, broadcast_tensors
import torch.nn.functional as F
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
# types
from typing import Optional, List, Union
# pytorch geometric
try:
import torch_geometric
from torch_geometric.nn import Message... | egnn-pytorch-main | egnn_pytorch/egnn_pytorch_geometric.py |
import torch
from egnn_pytorch import EGNN, EGNN_Sparse
from egnn_pytorch.utils import rot
torch.set_default_dtype(torch.float64)
def test_egnn_equivariance():
layer = EGNN(dim=512, edge_dim=4)
R = rot(*torch.rand(3))
T = torch.randn(1, 1, 3)
feats = torch.randn(1, 16, 512)
coors = torch.randn(... | egnn-pytorch-main | tests/test_equivariance.py |
from setuptools import setup, find_packages
setup(
name = 'token-shift-gpt',
packages = find_packages(),
version = '0.0.3',
license='MIT',
description = 'Token Shift GPT - Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url = 'https://github.com/lucidrains/token-shift-gpt',
key... | token-shift-gpt-main | setup.py |
from token_shift_gpt import TokenShiftGPT
from token_shift_gpt.autoregressive_wrapper import AutoregressiveWrapper
import random
import tqdm
import gzip
import numpy as np
import torch
import torch.optim as optim
from torch.nn import functional as F
from torch.utils.data import DataLoader, Dataset
# constants
NUM_BA... | token-shift-gpt-main | train.py |
import torch
from torch import nn
import torch.nn.functional as F
# helper function
def eval_decorator(fn):
def inner(model, *args, **kwargs):
was_training = model.training
model.eval()
out = fn(model, *args, **kwargs)
model.train(was_training)
return out
return inner
... | token-shift-gpt-main | token_shift_gpt/autoregressive_wrapper.py |
from token_shift_gpt.token_shift_gpt import TokenShiftGPT
| token-shift-gpt-main | token_shift_gpt/__init__.py |
from math import log2, ceil
import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange
# helper functions
def exists(val):
return val is not None
def shift(x, amt, dim = -1):
return F.pad(x, (*((0, 0) * (-dim - 1)), amt, -amt), value = 0.)
def shift_tokens(x, amt... | token-shift-gpt-main | token_shift_gpt/token_shift_gpt.py |
from setuptools import setup, find_packages
setup(
name = 'magic3d-pytorch',
packages = find_packages(exclude=[]),
version = '0.0.1',
license='MIT',
description = 'Magic3D - Nvidia\'s Text-to-3D',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_description_content_type = 'text/markdow... | magic3d-pytorch-main | setup.py |
magic3d-pytorch-main | magic3d_pytorch/magic3d_pytorch.py | |
magic3d-pytorch-main | magic3d_pytorch/__init__.py | |
import gdb
import re
import sys
import traceback
# some feedback that the nim runtime support is loading, isn't a bad
# thing at all.
gdb.write("Loading Nim Runtime support.\n", gdb.STDERR)
# When error occure they occur regularly. This 'caches' known errors
# and prevents them from being reprinted over and over agai... | Nim-devel | tools/nim-gdb.py |
import gdb
# this test should test the gdb pretty printers of the nim
# library. But be aware this test is not complete. It only tests the
# command line version of gdb. It does not test anything for the
# machine interface of gdb. This means if if this test passes gdb
# frontends might still be broken.
gdb.execute("s... | Nim-devel | tests/untestable/gdb/gdb_pretty_printer_test.py |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Generates the unidecode.dat module
# (c) 2010 Andreas Rumpf
from unidecode import unidecode
try:
import warnings
warnings.simplefilter("ignore")
except ImportError:
pass
def main():
f = open("unidecode.dat", "wb+")
for x in range(128, 0xffff + 1):
u = ev... | Nim-devel | lib/pure/unidecode/gen.py |
from setuptools import setup, find_packages
setup(
name = 'flash-attention-jax',
packages = find_packages(exclude=[]),
version = '0.3.1',
license='MIT',
description = 'Flash Attention - in Jax',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_description_content_type = 'text/markdown'... | flash-attention-jax-main | setup.py |
import jax
from jax import nn
from jax import jit, numpy as jnp
from jax.numpy import einsum
from einops import rearrange
EPSILON = 1e-10
MASK_VALUE = -1e10
COSINE_SIM_SCALE = 10
@jit
def attention(q, k, v, key_mask):
dim, k_len = q.shape[-1], k.shape[-2]
scale = 1 / jnp.sqrt(dim)
q = q * scale
sim ... | flash-attention-jax-main | flash_attention_jax/attention.py |
import math
from functools import partial
import jax
from jax import lax, numpy as jnp, jit
# constants
HIGHEST_PRECISION = jax.lax.Precision.HIGHEST
einsum = partial(jnp.einsum, precision = HIGHEST_PRECISION)
# Figure 1 from https://arxiv.org/abs/2112.05682
# cleaned up
def _query_chunk_attention(q, k, v, k_chun... | flash-attention-jax-main | flash_attention_jax/rabe_attention.py |
from flash_attention_jax.flash_attention import flash_attention
from flash_attention_jax.cosine_sim_flash_attention import cosine_sim_flash_attention
from flash_attention_jax.causal_flash_attention import causal_flash_attention
from flash_attention_jax.rabe_attention import rabe_attention
from flash_attention_jax.atten... | flash-attention-jax-main | flash_attention_jax/__init__.py |
import math
import jax
from functools import partial
from jax import nn
from jax import custom_vjp
from jax import numpy as jnp, lax, jit
# constants
EPSILON = 1e-10
MASK_VALUE = -1e10
Q_CHUNK_SIZE = 1024
K_CHUNK_SIZE = 1024
COSINE_SIM_SCALE = 10 # this may need to be a function of log(sequence length), but 16 was s... | flash-attention-jax-main | flash_attention_jax/cosine_sim_flash_attention.py |
import math
import jax
from functools import partial
from jax import nn
from jax import custom_vjp
from jax import numpy as jnp, lax, jit
from jax.numpy import einsum
from einops import rearrange
# constants
EPSILON = 1e-10
MASK_VALUE = -1e10
Q_CHUNK_SIZE = 1024
K_CHUNK_SIZE = 1024
# flash attention
def _query_ch... | flash-attention-jax-main | flash_attention_jax/causal_flash_attention.py |
import jax
from functools import partial
import jax.numpy as jnp
from jax import random
from jax import value_and_grad
def value_and_grad_wrapper(fn, **kwargs):
@partial(value_and_grad, **kwargs)
def inner(*args, **kwargs):
return jnp.sum(fn(*args, **kwargs))
return inner
def diff(t1, t2):
ret... | flash-attention-jax-main | flash_attention_jax/utils.py |
import math
import jax
from functools import partial
from jax import nn
from jax import custom_vjp
from jax import numpy as jnp, lax, jit
from jax.numpy import einsum
from einops import rearrange
# constants
EPSILON = 1e-10
MASK_VALUE = -1e10
Q_CHUNK_SIZE = 1024
K_CHUNK_SIZE = 1024
# flash attention
def _query_ch... | flash-attention-jax-main | flash_attention_jax/flash_attention.py |
from setuptools import setup, find_packages
setup(
name = 'hamburger-pytorch',
packages = find_packages(),
version = '0.0.3',
license='MIT',
description = 'Hamburger - Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url = 'https://github.com/lucidrains/hamburger-pytorch',
keywo... | hamburger-pytorch-main | setup.py |
import torch
from torch import nn, einsum
import torch.nn.functional as F
from contextlib import contextmanager
from einops import repeat, rearrange
# helper fn
@contextmanager
def null_context():
yield
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
# clas... | hamburger-pytorch-main | hamburger_pytorch/hamburger_pytorch.py |
from hamburger_pytorch.hamburger_pytorch import Hamburger
| hamburger-pytorch-main | hamburger_pytorch/__init__.py |
from setuptools import setup, find_packages
setup(
name = 'ITTR-pytorch',
packages = find_packages(exclude=[]),
version = '0.0.4',
license='MIT',
description = 'ITTR - Implementation of the Hybrid Perception Block and Dual-Pruned Self-Attention block',
author = 'Phil Wang',
author_email = 'lucidrains@gma... | ITTR-pytorch-main | setup.py |
from ITTR_pytorch.ITTR_pytorch import HPB, DPSA
| ITTR-pytorch-main | ITTR_pytorch/__init__.py |
import torch
import torch.nn.functional as F
from torch import nn, einsum
from einops import rearrange, reduce, repeat
# helper functions
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
def l2norm(t):
return F.normalize(t, dim = -1)
# helper classes
class... | ITTR-pytorch-main | ITTR_pytorch/ITTR_pytorch.py |
from setuptools import setup, find_packages
setup(
name = 'make-a-video-pytorch',
packages = find_packages(exclude=[]),
version = '0.3.1',
license='MIT',
description = 'Make-A-Video - Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_description_content_type = 'text/markdown',... | make-a-video-pytorch-main | setup.py |
from make_a_video_pytorch.make_a_video import PseudoConv3d, SpatioTemporalAttention
from make_a_video_pytorch.make_a_video import ResnetBlock, Downsample, Upsample
from make_a_video_pytorch.make_a_video import SpaceTimeUnet
| make-a-video-pytorch-main | make_a_video_pytorch/__init__.py |
from functools import wraps
from packaging import version
from collections import namedtuple
import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange
# constants
AttentionConfig = namedtuple('AttentionConfig', ['enable_flash', 'enable_math', 'enable_mem_efficient'])
# ... | make-a-video-pytorch-main | make_a_video_pytorch/attend.py |
import math
import functools
from operator import mul
import torch
import torch.nn.functional as F
from torch import nn, einsum
from einops import rearrange, repeat, pack, unpack
from einops.layers.torch import Rearrange
from make_a_video_pytorch.attend import Attend
# helper functions
def exists(val):
return ... | make-a-video-pytorch-main | make_a_video_pytorch/make_a_video.py |
from setuptools import setup, find_packages
exec(open('parti_pytorch/version.py').read())
setup(
name = 'parti-pytorch',
packages = find_packages(exclude=[]),
version = __version__,
license='MIT',
description = 'Parti - Pathways Autoregressive Text-to-Image Model - Pytorch',
author = 'Phil Wang',
author_... | parti-pytorch-main | setup.py |
__version__ = '0.0.18'
| parti-pytorch-main | parti_pytorch/version.py |
import torch
import transformers
from transformers import T5Tokenizer, T5EncoderModel, T5Config
transformers.logging.set_verbosity_error()
def exists(val):
return val is not None
# config
MAX_LENGTH = 256
DEFAULT_T5_NAME = 'google/t5-v1_1-base'
T5_CONFIGS = {}
# singleton globals
def get_tokenizer(name):
... | parti-pytorch-main | parti_pytorch/t5.py |
from math import sqrt
import copy
from random import choice
from pathlib import Path
from shutil import rmtree
from PIL import Image
import torch
from torch import nn
from torch.cuda.amp import autocast, GradScaler
from torch.utils.data import Dataset, DataLoader, random_split
import torchvision.transforms as T
from ... | parti-pytorch-main | parti_pytorch/vit_vqgan_trainer.py |
from parti_pytorch.parti_pytorch import Parti
from parti_pytorch.vit_vqgan import VitVQGanVAE
from parti_pytorch.vit_vqgan_trainer import VQGanVAETrainer | parti-pytorch-main | parti_pytorch/__init__.py |
import copy
import math
from math import sqrt
from functools import partial, wraps
from vector_quantize_pytorch import VectorQuantize as VQ
import torch
from torch import nn, einsum
import torch.nn.functional as F
from torch.autograd import grad as torch_grad
import torchvision
from einops import rearrange, reduce, ... | parti-pytorch-main | parti_pytorch/vit_vqgan.py |
from torch.optim import AdamW, Adam
def separate_weight_decayable_params(params):
wd_params, no_wd_params = [], []
for param in params:
param_list = no_wd_params if param.ndim < 2 else wd_params
param_list.append(param)
return wd_params, no_wd_params
def get_optimizer(
params,
lr =... | parti-pytorch-main | parti_pytorch/optimizer.py |
from typing import List
from functools import partial
import torch
import torch.nn.functional as F
from torch import nn, einsum
import torchvision.transforms as T
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
from parti_pytorch.t5 import t5_encode_text, get_encoded_dim, DEFAULT_T5_NA... | parti-pytorch-main | parti_pytorch/parti_pytorch.py |
from setuptools import setup, find_packages
setup(
name = 'musiclm-pytorch',
packages = find_packages(exclude=[]),
version = '0.2.8',
license='MIT',
description = 'MusicLM - AudioLM + Audio CLIP to text to music synthesis',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_description_c... | musiclm-pytorch-main | setup.py |
from musiclm_pytorch.musiclm_pytorch import (
MuLaN,
MuLaNEmbedQuantizer,
MusicLM,
AudioSpectrogramTransformer,
TextTransformer,
SigmoidContrastiveLearning,
SoftmaxContrastiveLearning
)
from musiclm_pytorch.trainer import MuLaNTrainer
| musiclm-pytorch-main | musiclm_pytorch/__init__.py |
import torch
from torch import nn
from torch.autograd import Function
import torch.distributed as dist
from einops import rearrange
# distributed helpers
def all_gather_same_dim(t):
world_size = dist.get_world_size()
gathered_tensors = [torch.empty_like(t, device = t.device, dtype = t.dtype) for i in range(w... | musiclm-pytorch-main | musiclm_pytorch/distributed.py |
import copy
from math import sqrt
from random import choice
from pathlib import Path
from shutil import rmtree
from functools import wraps, partial
from typing_extensions import Annotated
from beartype import beartype
from beartype.door import is_bearable
from beartype.vale import Is
from beartype.typing import Union... | musiclm-pytorch-main | musiclm_pytorch/trainer.py |
import math
from functools import wraps, partial
import torch
import torch.nn.functional as F
from torch import nn, einsum
from torchaudio.transforms import Spectrogram, TimeStretch, FrequencyMasking, TimeMasking
from audiolm_pytorch import AudioLM
from audiolm_pytorch.utils import AudioConditionerBase
import torch... | musiclm-pytorch-main | musiclm_pytorch/musiclm_pytorch.py |
from setuptools import setup, find_packages
setup(
name = 'discrete-key-value-bottleneck-pytorch',
packages = find_packages(exclude=[]),
version = '0.1.1',
license='MIT',
description = 'Discrete Key / Value Bottleneck - Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_descrip... | discrete-key-value-bottleneck-pytorch-main | setup.py |
from discrete_key_value_bottleneck_pytorch.discrete_key_value_bottleneck import DiscreteKeyValueBottleneck
| discrete-key-value-bottleneck-pytorch-main | discrete_key_value_bottleneck_pytorch/__init__.py |
import torch
from torch import nn, einsum
from einops import rearrange, repeat, reduce
from vector_quantize_pytorch import VectorQuantize
# helper functions
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
# main class
class DiscreteKeyValueBottleneck(nn.Module... | discrete-key-value-bottleneck-pytorch-main | discrete_key_value_bottleneck_pytorch/discrete_key_value_bottleneck.py |
from setuptools import setup, find_packages
setup(
name = 'axial_attention',
packages = find_packages(),
version = '0.6.1',
license='MIT',
description = 'Axial Attention',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url = 'https://github.com/lucidrains/axial-attention',
keywords = ['... | axial-attention-master | setup.py |
import torch
import torch.nn as nn
from torch.autograd.function import Function
from torch.utils.checkpoint import get_device_states, set_device_states
# following example for saving and setting rng here https://pytorch.org/docs/stable/_modules/torch/utils/checkpoint.html
class Deterministic(nn.Module):
def __init... | axial-attention-master | axial_attention/reversible.py |
from axial_attention.axial_attention import AxialAttention, AxialPositionalEmbedding, AxialImageTransformer, SelfAttention
| axial-attention-master | axial_attention/__init__.py |
import torch
from torch import nn
from operator import itemgetter
from axial_attention.reversible import ReversibleSequence
# helper functions
def exists(val):
return val is not None
def map_el_ind(arr, ind):
return list(map(itemgetter(ind), arr))
def sort_and_return_indices(arr):
indices = [ind for ind... | axial-attention-master | axial_attention/axial_attention.py |
from setuptools import setup, find_packages
setup(
name = 'metaformer-gpt',
packages = find_packages(exclude=[]),
version = '0.0.5',
license='MIT',
description = 'Metaformer - GPT',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_description_content_type = 'text/markdown',
url = 'ht... | metaformer-gpt-main | setup.py |
import gzip
import random
import numpy as np
import torch
import torch.optim as optim
import tqdm
from torch.nn import functional as F
from torch.utils.data import DataLoader, Dataset
from metaformer_gpt import MetaformerGPT
from metaformer_gpt.autoregressive_wrapper import AutoregressiveWrapper
# constants
NUM_BAT... | metaformer-gpt-main | train.py |
import torch
from torch import nn, einsum
from einops import rearrange, repeat
from scipy.fftpack import next_fast_len
# helper functions
def cummean(x, *, dim):
numer = x.cumsum(dim = dim)
denom = torch.arange(x.shape[1], device = x.device) + 1
return numer / rearrange(denom, '... -> ... 1')
def conv1d... | metaformer-gpt-main | metaformer_gpt/metaformer_gpt.py |
import torch
import torch.nn.functional as F
from einops import rearrange
from torch import nn
# helper function
def exists(val):
return val is not None
def eval_decorator(fn):
def inner(model, *args, **kwargs):
was_training = model.training
model.eval()
out = fn(model, *args, **kwa... | metaformer-gpt-main | metaformer_gpt/autoregressive_wrapper.py |
from metaformer_gpt.metaformer_gpt import MetaformerGPT, MultiheadExponentialTimeDecay
| metaformer-gpt-main | metaformer_gpt/__init__.py |
from setuptools import setup, find_packages
setup(
name = 'ddpm-ipa-protein-generation',
packages = find_packages(exclude=[]),
version = '0.0.1',
license='MIT',
description = 'DDPM + Invariant Point Attention - Protein Generation',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_descr... | ddpm-ipa-protein-generation-main | setup.py |
import torch
from torch import nn
# gaussian diffusion with continuous time helper functions and classes
# large part of this was thanks to @crowsonkb at https://github.com/crowsonkb/v-diffusion-jax/blob/master/diffusion/utils.py
@torch.jit.script
def beta_linear_log_snr(t):
return -torch.log(expm1(1e-4 + 10 * (t... | ddpm-ipa-protein-generation-main | ddpm_ipa_protein_generation/ddpm_ipa_protein_generation.py |
ddpm-ipa-protein-generation-main | ddpm_ipa_protein_generation/__init__.py | |
from setuptools import setup, find_packages
setup(
name = 'transframer-pytorch',
packages = find_packages(exclude=[]),
version = '0.0.1',
license='MIT',
description = 'Transframer - Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_description_content_type = 'text/markdown',
... | transframer-pytorch-main | setup.py |
from transframer_pytorch.transframer_pytorch import Transframer, Unet
| transframer-pytorch-main | transframer_pytorch/__init__.py |
from math import sqrt, pi
from functools import partial
import torch
import torch.nn.functional as F
from torch.fft import fft, irfft
from torch import nn, einsum
from einops import rearrange, repeat
from kornia.color.ycbcr import rgb_to_ycbcr, ycbcr_to_rgb
# helpers
def exists(val):
return val is not None
de... | transframer-pytorch-main | transframer_pytorch/transframer_pytorch.py |
from setuptools import setup, find_packages
setup(
name = 'multistream-transformers',
packages = find_packages(),
version = '0.0.4',
license='MIT',
description = 'Multistream Transformers - Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url = 'https://github.com/lucidrains/multi... | multistream-transformers-main | setup.py |
from multistream_transformers import MultistreamTransformer
from multistream_transformers.autoregressive_wrapper import AutoregressiveWrapper
import random
import tqdm
import gzip
import numpy as np
import torch
import torch.optim as optim
from torch.nn import functional as F
from torch.utils.data import DataLoader, D... | multistream-transformers-main | train.py |
import torch
from torch import nn
import torch.nn.functional as F
# helper function
def eval_decorator(fn):
def inner(model, *args, **kwargs):
was_training = model.training
model.eval()
out = fn(model, *args, **kwargs)
model.train(was_training)
return out
return inner
... | multistream-transformers-main | multistream_transformers/autoregressive_wrapper.py |
from multistream_transformers.multistream_transformers import MultistreamTransformer
| multistream-transformers-main | multistream_transformers/__init__.py |
import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange, repeat, reduce
from einops.layers.torch import Rearrange
# helper functions
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
def max_neg_value(t):
return... | multistream-transformers-main | multistream_transformers/multistream_transformers.py |
from setuptools import setup, find_packages
setup(
name = 'local-attention',
packages = find_packages(),
version = '1.8.6',
license='MIT',
description = 'Local attention, window with lookback, for language modeling',
long_description_content_type = 'text/markdown',
author = 'Phil Wang',
author_email = ... | local-attention-master | setup.py |
import random
import tqdm
import gzip
import numpy as np
import torch
from torch.optim import Adam
from torch.nn import functional as F
from torch.utils.data import DataLoader, Dataset
from local_attention import LocalTransformer
# constants
NUM_BATCHES = int(1e5)
BATCH_SIZE = 4
GRADIENT_ACCUMULATE_EVERY = 4
LEARNI... | local-attention-master | train.py |
from local_attention.local_attention import LocalAttention
from local_attention.transformer import LocalTransformer, LocalMHA, DynamicPositionBias
| local-attention-master | local_attention/__init__.py |
import torch
from torch import nn
import torch.nn.functional as F
from einops import rearrange
from local_attention.local_attention import LocalAttention
# helper function
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
def l2norm(t):
return F.normalize(t,... | local-attention-master | local_attention/transformer.py |
import math
import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange, repeat, pack, unpack
from local_attention.rotary import SinusoidalEmbeddings, apply_rotary_pos_emb
# constant
TOKEN_SELF_ATTN_VALUE = -5e4
# helper functions
def exists(val):
return val is not ... | local-attention-master | local_attention/local_attention.py |
import torch
from torch import nn, einsum
from einops import rearrange
def exists(val):
return val is not None
class SinusoidalEmbeddings(nn.Module):
def __init__(
self,
dim,
scale_base = None,
use_xpos = False
):
super().__init__()
inv_freq = 1. / (10000 *... | local-attention-master | local_attention/rotary.py |
from setuptools import setup, find_packages
setup(
name = 'resize-right',
packages = find_packages(exclude=[]),
version = '0.0.2',
license = 'MIT',
description = 'Resize Right',
author = 'Assaf Shocher',
author_email = 'assafshocher@gmail.com',
url = 'https://github.com/assafshocher/ResizeRight',
key... | ResizeRight-master | setup.py |
from resize_right.resize_right import resize
import resize_right.interp_methods as interp_methods
| ResizeRight-master | resize_right/__init__.py |
from math import pi
try:
import torch
except ImportError:
torch = None
try:
import numpy
except ImportError:
numpy = None
if numpy is None and torch is None:
raise ImportError("Must have either Numpy or PyTorch but both not found")
def set_framework_dependencies(x):
if type(x) is numpy.ndar... | ResizeRight-master | resize_right/interp_methods.py |
from typing import Tuple
import warnings
from math import ceil
from fractions import Fraction
import resize_right.interp_methods as interp_methods
class NoneClass:
pass
try:
import torch
from torch import nn
nnModuleWrapped = nn.Module
except ImportError:
warnings.warn('No PyTorch found, will wo... | ResizeRight-master | resize_right/resize_right.py |
from setuptools import setup, find_packages
setup(
name = 'stam-pytorch',
packages = find_packages(),
version = '0.0.4',
license='MIT',
description = 'Space Time Attention Model (STAM) - Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url = 'https://github.com/lucidrains/STAM-pyt... | STAM-pytorch-main | setup.py |
from stam_pytorch.stam import STAM
| STAM-pytorch-main | stam_pytorch/__init__.py |
import torch
from torch import nn, einsum
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
class PreNorm(nn.Module):
def __init__(self, dim, fn):
super().__init__()
self.norm = nn.LayerNorm(dim)
self.fn = fn
def forward(self, x, **kwargs):
return s... | STAM-pytorch-main | stam_pytorch/stam.py |
from setuptools import setup, find_packages
setup(
name = 'bit-diffusion',
packages = find_packages(exclude=[]),
version = '0.1.2',
license='MIT',
description = 'Bit Diffusion - Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_description_content_type = 'text/markdown',
url... | bit-diffusion-main | setup.py |
import math
from pathlib import Path
from functools import partial
from multiprocessing import cpu_count
import torch
from torch import nn, einsum
from torch.special import expm1
import torch.nn.functional as F
from torch.utils.data import Dataset, DataLoader
from torch.optim import Adam
from torchvision import trans... | bit-diffusion-main | bit_diffusion/bit_diffusion.py |
from bit_diffusion.bit_diffusion import Unet, BitDiffusion, Trainer
| bit-diffusion-main | bit_diffusion/__init__.py |
from setuptools import setup, find_packages
setup(
name = 'ETSformer-pytorch',
packages = find_packages(exclude=[]),
version = '0.1.1',
license='MIT',
description = 'ETSTransformer - Exponential Smoothing Transformer for Time-Series Forecasting - Pytorch',
long_description_content_type = 'text/markdown',
... | ETSformer-pytorch-main | setup.py |
from etsformer_pytorch.etsformer_pytorch import (
ETSFormer,
ClassificationWrapper,
MHESA
)
| ETSformer-pytorch-main | etsformer_pytorch/__init__.py |
from math import pi
from collections import namedtuple
import torch
import torch.nn.functional as F
from torch import nn, einsum
from scipy.fftpack import next_fast_len
from einops import rearrange, repeat
from einops.layers.torch import Rearrange
# constants
Intermediates = namedtuple('Intermediates', ['growth_lat... | ETSformer-pytorch-main | etsformer_pytorch/etsformer_pytorch.py |
from setuptools import setup, find_packages
setup(
name = 'MEGABYTE-pytorch',
packages = find_packages(),
version = '0.2.1',
license='MIT',
description = 'MEGABYTE - Pytorch',
long_description_content_type = 'text/markdown',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url = 'https://... | MEGABYTE-pytorch-main | setup.py |
from MEGABYTE_pytorch import MEGABYTE
import random
import tqdm
import gzip
import numpy as np
import torch
import torch.optim as optim
from torch.nn import functional as F
from torch.utils.data import DataLoader, Dataset
# constants
NUM_BATCHES = int(1e5)
BATCH_SIZE = 4
GRADIENT_ACCUMULATE_EVERY = 4
LEARNING_RATE =... | MEGABYTE-pytorch-main | train.py |
from MEGABYTE_pytorch.megabyte import MEGABYTE
| MEGABYTE-pytorch-main | MEGABYTE_pytorch/__init__.py |
from collections import namedtuple
from functools import wraps
from packaging import version
import torch
from torch import nn, einsum
import torch.nn.functional as F
from einops import rearrange
# constants
EfficientAttentionConfig = namedtuple('EfficientAttentionConfig', ['enable_flash', 'enable_math', 'enable_me... | MEGABYTE-pytorch-main | MEGABYTE_pytorch/attend.py |
import math
import functools
from itertools import zip_longest
import torch
import torch.nn.functional as F
from torch import nn, einsum
from einops import rearrange, reduce, repeat, pack, unpack
from einops.layers.torch import Rearrange
from beartype import beartype
from beartype.typing import Tuple, Union
from ME... | MEGABYTE-pytorch-main | MEGABYTE_pytorch/megabyte.py |
# Copyright 2019 Deepmind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... | deepmind-research-master | __init__.py |
# Lint as: python3
# Copyright 2019 Deepmind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | deepmind-research-master | iodine/configurations.py |
# Lint as: python3
# Copyright 2019 Deepmind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | deepmind-research-master | iodine/main.py |
# Lint as: python3
# Copyright 2019 Deepmind Technologies Limited.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | deepmind-research-master | iodine/modules/decoder.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.