python_code
stringlengths
0
1.02M
repo_name
stringlengths
9
48
file_path
stringlengths
5
114
from .adamod import AdaMod
AdaMod-master
adamod/__init__.py
import math import torch from torch.optim import Optimizer class AdaMod(Optimizer): """Implements AdaMod algorithm with Decoupled Weight Decay (arxiv.org/abs/1711.05101) It has been proposed in `Adaptive and Momental Bounds for Adaptive Learning Rate Methods`_. Arguments: params (iterable): iterabl...
AdaMod-master
adamod/adamod.py
import os #%matplotlib notebook import matplotlib.pyplot as plt import torch import numpy as np LABELS = ['SGD','Adam', 'AdaMod'] def get_folder_path(use_pretrained=True): if use_pretrained: path = 'pretrained' else: path = 'curve' return path def get_curve_data(use_pretrained=True, model...
AdaMod-master
demos/cifar100/visualization.py
"""Train CIFAR100 with PyTorch.""" from __future__ import print_function import torch import torch.optim as optim import torch.backends.cudnn as cudnn import torchvision import torchvision.transforms as transforms import os import argparse from models import * from adamod import AdaMod def get_parser(): parser ...
AdaMod-master
demos/cifar100/main.py
""" .. Densely Connected Convolutional Networks: https://arxiv.org/abs/1608.06993 """ import math import torch import torch.nn as nn import torch.nn.functional as F class Bottleneck(nn.Module): def __init__(self, in_planes, growth_rate): super(Bottleneck, self).__init__() self.bn1 = nn.BatchN...
AdaMod-master
demos/cifar100/models/densenet.py
from .resnet import * from .densenet import *
AdaMod-master
demos/cifar100/models/__init__.py
""" .. Deep Residual Learning for Image Recognition: https://arxiv.org/abs/1512.03385 """ import torch import torch.nn as nn import torch.nn.functional as F class BasicBlock(nn.Module): expansion = 1 def __init__(self, in_planes, planes, stride=1): super(BasicBlock, self).__init__() self....
AdaMod-master
demos/cifar100/models/resnet.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. import importlib import os from ....
AdaMod-master
demos/nmt/lr_scheduler/__init__.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from . import FairseqLRScheduler, ...
AdaMod-master
demos/nmt/lr_scheduler/cold_start_scheduler.py
from setuptools import setup, find_packages setup( name = 'uniformer-pytorch', packages = find_packages(), version = '0.0.4', license='MIT', description = 'Uniformer - Pytorch', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', url = 'https://github.com/lucidrains/uniformer-pytorch', keywo...
uniformer-pytorch-main
setup.py
import torch from torch import nn, einsum from einops import rearrange from einops.layers.torch import Reduce # helpers def exists(val): return val is not None # classes class LayerNorm(nn.Module): def __init__(self, dim, eps = 1e-5): super().__init__() self.eps = eps self.g = nn.Par...
uniformer-pytorch-main
uniformer_pytorch/uniformer_pytorch.py
from uniformer_pytorch.uniformer_pytorch import Uniformer
uniformer-pytorch-main
uniformer_pytorch/__init__.py
import csv from clap.datasets import tokenize import torch import torchaudio # constants MAX_TOKEN_LENGTH = 256 DATA_DIR = './data' NUM_MEL = 80 TSV_FILE_NAME = 'subset.tsv' # helpers def tsv_to_dict(path): with open(path) as fd: rd = csv.DictReader(fd, delimiter = "\t", quotechar = '"') return...
CLAP-main
preprocess.py
from setuptools import setup, find_packages setup( name="clap-jax", packages=find_packages(), version="0.0.1", license="MIT", description="CLAP - Contrastive Language-Audio Pretraining", author="Charles Foster", author_email="", url="https://github.com/cfoster0/CLAP", keywords=[ ...
CLAP-main
setup.py
import click from click_option_group import optgroup import jax from jax import random, numpy as np, value_and_grad, jit, tree_util from optax import chain, clip_by_global_norm, scale_by_adam, scale, apply_updates, add_decayed_weights, masked from clap.models import CLAP # data from torch.utils.data import DataLoad...
CLAP-main
train.py
import jax from typing import Any, Callable, Sequence, Optional from jax import lax, random, numpy as np, vmap, jit from jax.ops import index, index_update # einsum and einops from jax.numpy import einsum from einops import rearrange, repeat # flax import flax from flax.core import freeze, unfreeze from flax import...
CLAP-main
clap/models.py
import glob import torch from pathlib import Path import lm_dataformat as lmd from itertools import cycle, islice, chain import torch.nn.functional as F from torch.utils.data import Dataset, TensorDataset, ConcatDataset, IterableDataset class CaptionedAudioMetadataset(IterableDataset): def __init__(self, path_p...
CLAP-main
clap/datasets.py
from clap.models import CLAP from clap.datasets import CaptionedAudioDataset, CaptionedAudioMetadataset, tokenize
CLAP-main
clap/__init__.py
# Modified from Google's Vision Transformer repo, whose notice is reproduced below. # # Copyright 2021 Google LLC. # # 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.or...
CLAP-main
clap/trunks.py
from setuptools import setup, find_packages setup( name = 'robocat-pytorch', packages = find_packages(exclude=[]), version = '0.0.1', license='MIT', description = 'RoboCat - A Self-Improving Foundation Agent for Robotic Manipulation', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', long_de...
robocat-pytorch-main
setup.py
robocat-pytorch-main
robocat_pytorch/__init__.py
robocat-pytorch-main
robocat_pytorch/robocat.py
from setuptools import setup, find_packages exec(open('gigagan_pytorch/version.py').read()) setup( name = 'gigagan-pytorch', packages = find_packages(exclude=[]), version = __version__, license='MIT', description = 'GigaGAN - Pytorch', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', long_...
gigagan-pytorch-main
setup.py
__version__ = '0.2.19'
gigagan-pytorch-main
gigagan_pytorch/version.py
from collections import namedtuple from pathlib import Path from math import log2, sqrt from random import random from functools import partial from torchvision import utils import torch import torch.nn.functional as F from torch import nn, einsum, Tensor from torch.autograd import grad as torch_grad from torch.utils...
gigagan-pytorch-main
gigagan_pytorch/gigagan_pytorch.py
from math import log2 from functools import partial import torch from torch import nn import torch.nn.functional as F from einops import rearrange, repeat from einops.layers.torch import Rearrange from gigagan_pytorch.attend import Attend from gigagan_pytorch.gigagan_pytorch import ( BaseGenerator, StyleNetw...
gigagan-pytorch-main
gigagan_pytorch/unet_upsampler.py
from gigagan_pytorch.gigagan_pytorch import ( GigaGAN, Generator, Discriminator, VisionAidedDiscriminator, AdaptiveConv2DMod, StyleNetwork, TextEncoder ) from gigagan_pytorch.unet_upsampler import UnetUpsampler from gigagan_pytorch.data import ( ImageDataset, TextImageDataset, ...
gigagan-pytorch-main
gigagan_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 # constants AttentionConfig = namedtuple('AttentionConfig', ['enable_flash', 'enable_math', 'enable_mem_efficient']) # helpers def exists(val): ...
gigagan-pytorch-main
gigagan_pytorch/attend.py
import torch import torch.nn.functional as F from torch.autograd import Function import torch.distributed as dist from einops import rearrange # helpers def exists(val): return val is not None def pad_dim_to(t, length, dim = 0): pad_length = length - t.shape[dim] zero_pairs = (-dim - 1) if dim < 0 else ...
gigagan-pytorch-main
gigagan_pytorch/distributed.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 =...
gigagan-pytorch-main
gigagan_pytorch/optimizer.py
from functools import partial from pathlib import Path import torch from torch import nn from torch.utils.data import Dataset, DataLoader from PIL import Image from torchvision import transforms as T from beartype.door import is_bearable from beartype.typing import Tuple # helper functions def exists(val): ret...
gigagan-pytorch-main
gigagan_pytorch/data.py
import torch from torch import nn, einsum import torch.nn.functional as F import open_clip from einops import rearrange from beartype import beartype from beartype.typing import List, Optional def exists(val): return val is not None def l2norm(t): return F.normalize(t, dim = -1) class OpenClipAdapter(nn.Mo...
gigagan-pytorch-main
gigagan_pytorch/open_clip.py
import bitsandbytes as bnb import torch p = torch.nn.Parameter(torch.rand(10,10).cuda()) a = torch.rand(10,10).cuda() p1 = p.data.sum().item() adam = bnb.optim.Adam([p]) out = a*p loss = out.sum() loss.backward() adam.step() p2 = p.data.sum().item() assert p1 != p2 print('SUCCESS!') print('Installation was succes...
bitsandbytes-main
check_bnb_install.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import glob import os from setuptools import find_packages, setup libs = list(glob.glob("./bitsandbytes/libbitsandbytes*.so")) libs = [os.pat...
bitsandbytes-main
setup.py
import math import random import time from itertools import product import einops import pytest import torch import numpy as np import bitsandbytes as bnb from bitsandbytes import functional as F from scipy.stats import norm torch.set_printoptions( precision=5, sci_mode=False, linewidth=120, edgeitems=20, thresh...
bitsandbytes-main
tests/test_functional.py
import ctypes import os import shutil import time import uuid from itertools import product from os.path import join import pytest from lion_pytorch import Lion import torch import bitsandbytes as bnb import bitsandbytes.functional as F # import apex k = 20 def get_temp_dir(): path = f"/tmp/autoswap/{str(uui...
bitsandbytes-main
tests/test_optim.py
import os from typing import List, NamedTuple import pytest import bitsandbytes as bnb from bitsandbytes.cuda_setup.main import ( CUDA_RUNTIME_LIB, determine_cuda_runtime_lib_path, evaluate_cuda_setup, extract_candidate_paths, ) """ 'LD_LIBRARY_PATH': ':/mnt/D/titus/local/cuda-11.1/lib64/' 'CONDA_EXE...
bitsandbytes-main
tests/test_cuda_setup_evaluator.py
import bitsandbytes as bnb import pytest import torch from bitsandbytes import functional as F from bitsandbytes.autograd import get_inverse_transform_indices, undo_layout from bitsandbytes.nn.modules import Linear8bitLt # contributed by Alex Borzunov, see: # https://github.com/bigscience-workshop/petals/blob/main/te...
bitsandbytes-main
tests/test_linear8bitlt.py
from itertools import permutations, product import pytest import torch import bitsandbytes as bnb n = 1 k = 25 dim1 = torch.randint(16, 64, size=(n,)).tolist() dim2 = torch.randint(32, 96, size=(n,)).tolist() dim3 = torch.randint(32, 96, size=(n,)).tolist() dim4 = torch.randint(32, 96, size=(n,)).tolist() funcs = [(...
bitsandbytes-main
tests/test_autograd.py
from itertools import product import pytest import torch from torch import nn import bitsandbytes as bnb class MockArgs: def __init__(self, initial_data): for key in initial_data: setattr(self, key, initial_data[key]) class MLP8bit(torch.nn.Module): def __init__(self, dim1, dim2, has_f...
bitsandbytes-main
tests/test_modules.py
import ctypes as ct import os import torch from pathlib import Path from warnings import warn from bitsandbytes.cuda_setup.main import CUDASetup setup = CUDASetup.get_instance() if setup.initialized != True: setup.run_cuda_setup() if 'BITSANDBYTES_NOWELCOME' not in os.environ or str(os.environ['BITSANDBYTES...
bitsandbytes-main
bitsandbytes/cextension.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import cuda_setup, utils from .autograd._functions import ( MatmulLtState, bmm_cublas, matmul, matmul_cublas, mm_cu...
bitsandbytes-main
bitsandbytes/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import ctypes as ct import itertools import operator import random import torch import itertools import math from functools import reduce # R...
bitsandbytes-main
bitsandbytes/functional.py
import shlex import subprocess from typing import Tuple def execute_and_return(command_string: str) -> Tuple[str, str]: def _decode(subprocess_err_out_tuple): return tuple( to_decode.decode("UTF-8").strip() for to_decode in subprocess_err_out_tuple ) def execute_and_re...
bitsandbytes-main
bitsandbytes/utils.py
import os import sys from warnings import warn import torch HEADER_WIDTH = 60 def print_header( txt: str, width: int = HEADER_WIDTH, filler: str = "+" ) -> None: txt = f" {txt} " if txt else "" print(txt.center(width, filler)) def print_debug_info() -> None: print( "\nAbove we output some ...
bitsandbytes-main
bitsandbytes/__main__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .modules import Int8Params, Linear8bitLt, StableEmbedding
bitsandbytes-main
bitsandbytes/nn/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Optional, TypeVar, Union, overload import torch import torch.nn.functional as F from torch import Tensor, device, dtype, nn...
bitsandbytes-main
bitsandbytes/nn/modules.py
import operator import warnings from dataclasses import dataclass from functools import reduce # Required in Python 3 from typing import Tuple, Optional import torch import bitsandbytes.functional as F # math.prod not compatible with python < 3.8 def prod(iterable): return reduce(operator.mul, iterable, 1) te...
bitsandbytes-main
bitsandbytes/autograd/_functions.py
from ._functions import undo_layout, get_inverse_transform_indices
bitsandbytes-main
bitsandbytes/autograd/__init__.py
bitsandbytes-main
bitsandbytes/cuda_setup/__init__.py
import os from typing import Dict def to_be_ignored(env_var: str, value: str) -> bool: ignorable = { "PWD", # PWD: this is how the shell keeps track of the current working dir "OLDPWD", "SSH_AUTH_SOCK", # SSH stuff, therefore unrelated "SSH_TTY", "HOME", # Linux shell de...
bitsandbytes-main
bitsandbytes/cuda_setup/env_vars.py
""" extract factors the build is dependent on: [X] compute capability [ ] TODO: Q - What if we have multiple GPUs of different makes? - CUDA version - Software: - CPU-only: only CPU quantization functions (no optimizer, no matrix multipl) - CuBLAS-LT: full-build 8-bit optimizer - no CuBLAS-LT: no 8-bit ...
bitsandbytes-main
bitsandbytes/cuda_setup/main.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from bitsandbytes.optim.optimizer import Optimizer1State class RMSprop(Optimizer1State): def __init__( self, params, ...
bitsandbytes-main
bitsandbytes/optim/rmsprop.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from bitsandbytes.optim.optimizer import Optimizer1State class Lion(Optimizer1State): def __init__( self, params, ...
bitsandbytes-main
bitsandbytes/optim/lion.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from bitsandbytes.optim.optimizer import Optimizer2State class LAMB(Optimizer2State): def __init__( self, params, ...
bitsandbytes-main
bitsandbytes/optim/lamb.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from bitsandbytes.optim.optimizer import Optimizer1State class SGD(Optimizer1State): def __init__( self, params, ...
bitsandbytes-main
bitsandbytes/optim/sgd.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch from torch.optim import Optimizer from bitsandbytes.optim.optimizer import Optimizer1State class LARS(Optimizer1State): def...
bitsandbytes-main
bitsandbytes/optim/lars.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from bitsandbytes.cextension import COMPILED_WITH_CUDA from .adagrad import Adagrad, Adagrad8bit, Adagrad32bit from .adam import Adam, Adam8b...
bitsandbytes-main
bitsandbytes/optim/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from bitsandbytes.optim.optimizer import Optimizer1State class Adagrad(Optimizer1State): def __init__( self, params, ...
bitsandbytes-main
bitsandbytes/optim/adagrad.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from bitsandbytes.optim.optimizer import Optimizer2State class AdamW(Optimizer2State): def __init__( self, params, ...
bitsandbytes-main
bitsandbytes/optim/adamw.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import os import torch import torch.distributed as dist import bitsandbytes.functional as F from bitsandbytes.optim.optimizer im...
bitsandbytes-main
bitsandbytes/optim/adam.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections import abc as container_abcs from collections import defaultdict from copy import deepcopy from itertools import chain import...
bitsandbytes-main
bitsandbytes/optim/optimizer.py
from setuptools import setup, find_packages setup( name = 'anymal-belief-state-encoder-decoder-pytorch', packages = find_packages(exclude=[]), version = '0.0.20', license='MIT', description = 'Anymal Belief-state Encoder Decoder - Pytorch', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', u...
anymal-belief-state-encoder-decoder-pytorch-main
setup.py
from anymal_belief_state_encoder_decoder_pytorch.networks import Student, Teacher, MLP, Anymal from anymal_belief_state_encoder_decoder_pytorch.ppo import PPO, MockEnv
anymal-belief-state-encoder-decoder-pytorch-main
anymal_belief_state_encoder_decoder_pytorch/__init__.py
import torch from torch import nn import torch.nn.functional as F from torch.nn import GRUCell from torch.distributions import Categorical from torch.optim import Adam from einops import rearrange from einops_exts import check_shape from einops.layers.torch import Rearrange from anymal_belief_state_encoder_decoder_py...
anymal-belief-state-encoder-decoder-pytorch-main
anymal_belief_state_encoder_decoder_pytorch/networks.py
import torch from torch import nn from torch.utils.data import Dataset, DataLoader from torch.optim import Adam from collections import deque from einops import rearrange from anymal_belief_state_encoder_decoder_pytorch import Anymal class ExperienceDataset(Dataset): def __init__(self, data): super().__i...
anymal-belief-state-encoder-decoder-pytorch-main
anymal_belief_state_encoder_decoder_pytorch/trainer.py
from collections import namedtuple, deque import torch from torch import nn from torch.utils.data import Dataset, DataLoader from torch.optim import Adam from anymal_belief_state_encoder_decoder_pytorch import Anymal from anymal_belief_state_encoder_decoder_pytorch.networks import unfreeze_all_layers_ from einops im...
anymal-belief-state-encoder-decoder-pytorch-main
anymal_belief_state_encoder_decoder_pytorch/ppo.py
import torch from torch import nn class RunningStats(nn.Module): def __init__(self, shape, eps = 1e-5): super().__init__() shape = shape if isinstance(shape, tuple) else (shape,) self.shape = shape self.eps = eps self.n = 0 self.register_buffer('old_mean', torch.ze...
anymal-belief-state-encoder-decoder-pytorch-main
anymal_belief_state_encoder_decoder_pytorch/running.py
from setuptools import find_packages, setup setup( name="PaLM-pytorch", packages=find_packages(exclude=[]), version="0.2.2", license="MIT", description="PaLM: Scaling Language Modeling with Pathways - Pytorch", author="Phil Wang", author_email="lucidrains@gmail.com", long_description_co...
PaLM-pytorch-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 palm_pytorch.triton import PaLM from palm_pytorch.autoregressive_wrapper import AutoregressiveWrapper # constants NUM_BATCHES =...
PaLM-pytorch-main
train.py
import torch import torch.nn.functional as F from einops import rearrange from torch import einsum, nn # normalization # they use layernorm without bias, something that pytorch does not offer class LayerNorm(nn.Module): def __init__(self, dim): super().__init__() self.gamma = nn.Parameter(torch.o...
PaLM-pytorch-main
palm_pytorch/palm_pytorch.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...
PaLM-pytorch-main
palm_pytorch/autoregressive_wrapper.py
from palm_pytorch.palm_pytorch import PaLM
PaLM-pytorch-main
palm_pytorch/__init__.py
import torch import torch.nn.functional as F from einops import rearrange, repeat from torch import einsum, nn from math import log2, floor def exists(val): return val is not None # normalization class RMSNorm(nn.Module): def __init__(self, dim, eps = 1e-8): super().__init__() self.scale = di...
PaLM-pytorch-main
palm_pytorch/palm_lite.py
import torch import torch.nn.functional as F from einops import rearrange from torch import einsum, nn from palm_pytorch.triton.softmax import causal_softmax from palm_pytorch.triton.layernorm import layernorm_without_bias # normalization class LayerNorm(nn.Module): def __init__(self, dim): super().__ini...
PaLM-pytorch-main
palm_pytorch/triton/palm.py
# taken from Phil Tillet's layernorm tutorial for Triton # Triton - https://triton-lang.org # Layernorm tutorial - https://triton-lang.org/master/getting-started/tutorials/05-layer-norm.html#sphx-glr-getting-started-tutorials-05-layer-norm-py # modified to be bias-less import torch import triton import triton.languag...
PaLM-pytorch-main
palm_pytorch/triton/layernorm.py
from palm_pytorch.triton.palm import PaLM
PaLM-pytorch-main
palm_pytorch/triton/__init__.py
import torch from torch import autograd import torch.nn.functional as F import triton import triton.language as tl from triton_transformer.utils import calc_num_warps @triton.jit def softmax_kernel_forward( output_ptr, input_ptr, input_row_stride, output_row_stride, n_cols, BLOCK_SIZE: tl.cons...
PaLM-pytorch-main
palm_pytorch/triton/softmax.py
import deepspeed from palm_pytorch import PaLM from palm_pytorch.autoregressive_wrapper import AutoregressiveWrapper import random import tqdm import gzip import numpy as np import torch import torch.optim as optim from einops import rearrange from torch import einsum, nn import torch.nn.functional as F from torch.ut...
PaLM-pytorch-main
examples/enwik8_deepspeed/train.py
from setuptools import setup, find_packages setup( name = 'bottleneck-transformer-pytorch', packages = find_packages(), version = '0.1.4', license='MIT', description = 'Bottleneck Transformer - Pytorch', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', url = 'https://github.com/lucidrains/b...
bottleneck-transformer-pytorch-main
setup.py
from bottleneck_transformer_pytorch.bottleneck_transformer_pytorch import BottleStack, BottleBlock
bottleneck-transformer-pytorch-main
bottleneck_transformer_pytorch/__init__.py
import math import torch from torch import nn, einsum from einops import rearrange # translated from tensorflow code # https://gist.github.com/aravindsrinivas/56359b79f0ce4449bcb04ab4b56a57a2 # positional embedding helpers def pair(x): return (x, x) if not isinstance(x, tuple) else x def expand_dim(t, dim, k):...
bottleneck-transformer-pytorch-main
bottleneck_transformer_pytorch/bottleneck_transformer_pytorch.py
from setuptools import setup, find_packages setup( name = 'omninet-pytorch', packages = find_packages(), version = '0.0.6', license='MIT', description = 'Omninet - Pytorch', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', url = 'https://github.com/lucidrains/omninet-pytorch', keywords = ...
omninet-pytorch-main
setup.py
import torch from torch import nn, einsum import torch.nn.functional as F from einops import rearrange, repeat from einops.layers.torch import Rearrange # use Performer, as it had the best reported numbers from performer_pytorch import SelfAttention as PerformerAttention # helpers def exists(val): return val i...
omninet-pytorch-main
omninet_pytorch/omninet_pytorch.py
from omninet_pytorch.omninet_pytorch import Omninet, OmninetCausal
omninet-pytorch-main
omninet_pytorch/__init__.py
from setuptools import setup, find_packages setup( name = 'nystrom-attention', packages = find_packages(), version = '0.0.11', license='MIT', description = 'Nystrom Attention - Pytorch', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', url = 'https://github.com/lucidrains/nystrom-attention'...
nystrom-attention-main
setup.py
from math import ceil import torch from torch import nn, einsum import torch.nn.functional as F from einops import rearrange, reduce # helper functions def exists(val): return val is not None def moore_penrose_iter_pinv(x, iters = 6): device = x.device abs_x = torch.abs(x) col = abs_x.sum(dim = -1)...
nystrom-attention-main
nystrom_attention/nystrom_attention.py
from nystrom_attention.nystrom_attention import NystromAttention, Nystromformer Nystromer = Nystromformer
nystrom-attention-main
nystrom_attention/__init__.py
import os from copy import deepcopy import torch import torch.multiprocessing as mp import torch.distributed as dist from torch.nn.parallel import DistributedDataParallel as DDP from soft_moe_pytorch.soft_moe import Experts, FeedForward as Expert from soft_moe_pytorch.distributed import all_gather_variable_dim def s...
soft-moe-pytorch-main
assert.py
from setuptools import setup, find_packages setup( name = 'soft-moe-pytorch', packages = find_packages(exclude=[]), version = '0.0.9', license='MIT', description = 'Soft MoE - Pytorch', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', long_description_content_type = 'text/markdown', url =...
soft-moe-pytorch-main
setup.py
from soft_moe_pytorch.soft_moe import SoftMoE from soft_moe_pytorch.soft_moe_with_dynamic_slots import DynamicSlotsSoftMoE
soft-moe-pytorch-main
soft_moe_pytorch/__init__.py
import torch from torch import nn import torch.nn.functional as F from torch.autograd import Function import torch.distributed as dist from einops import rearrange, pack, unpack def exists(val): return val is not None def default(val, d): return val if exists(val) else d def divisible_by(num, den): ret...
soft-moe-pytorch-main
soft_moe_pytorch/distributed.py
import math import torch from torch.nn import Module import torch.nn.functional as F from torch import nn, einsum, Tensor from einops import rearrange, reduce, pack, unpack from einops.layers.torch import Rearrange # helper functions def exists(val): return val is not None def default(val, d): return val i...
soft-moe-pytorch-main
soft_moe_pytorch/soft_moe_with_dynamic_slots.py
import torch from torch.nn import Module import torch.nn.functional as F import torch.distributed as dist from torch import nn, einsum, Tensor from einops import rearrange, pack, unpack from soft_moe_pytorch.distributed import ( AllGather, split_by_rank, gather_sizes, has_only_one_value ) # helper fu...
soft-moe-pytorch-main
soft_moe_pytorch/soft_moe.py
from setuptools import setup, find_packages setup( name = 'sinkhorn_transformer', packages = find_packages(exclude=['examples']), version = '0.11.4', license='MIT', description = 'Sinkhorn Transformer - Sparse Sinkhorn Attention', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', url = 'http...
sinkhorn-transformer-master
setup.py
import torch from sinkhorn_transformer.sinkhorn_transformer import SinkhornTransformerLM from sinkhorn_transformer.autoregressive_wrapper import AutoregressiveWrapper N_BATCH = 16 SRC_SEQ_LEN = 512 TGT_SEQ_LEN = 512 enc = SinkhornTransformerLM( num_tokens = 64, dim = 512, depth = 1, heads = 8, max...
sinkhorn-transformer-master
examples/increment_by_one/train.py
import deepspeed from sinkhorn_transformer import SinkhornTransformerLM from sinkhorn_transformer.autoregressive_wrapper import AutoregressiveWrapper import argparse 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....
sinkhorn-transformer-master
examples/enwik8_deepspeed/train.py
from sinkhorn_transformer import SinkhornTransformerLM from sinkhorn_transformer.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 #...
sinkhorn-transformer-master
examples/enwik8_simple/train.py
import math import torch from torch import nn import torch.nn.functional as F from sinkhorn_transformer.sinkhorn_transformer import SinkhornTransformer, SinkhornTransformerLM def find_module(nn_module, type): for module in nn_module.modules(): if isinstance(module, type): return module retu...
sinkhorn-transformer-master
sinkhorn_transformer/autopadder.py
from functools import partial import torch from random import randint from torch import nn import torch.nn.functional as F from torch.nn.utils.rnn import pad_sequence from sinkhorn_transformer.sinkhorn_transformer import SinkhornTransformerLM from sinkhorn_transformer.autopadder import Autopadder def default(value, de...
sinkhorn-transformer-master
sinkhorn_transformer/autoregressive_wrapper.py