python_code stringlengths 0 1.02M | repo_name stringlengths 9 48 | file_path stringlengths 5 114 |
|---|---|---|
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | config.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | pretrained_example.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | train.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | metrics/linear_separability.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | metrics/frechet_inception_distance.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | metrics/__init__.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | metrics/perceptual_path_length.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | metrics/metric_base.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | training/misc.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | training/__init__.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | stylegan-master | training/networks_stylegan.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | training/training_loop.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | training/dataset.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | training/loss.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | training/networks_progan.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | dnnlib/util.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | stylegan-master | dnnlib/__init__.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | stylegan-master | dnnlib/tflib/__init__.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | stylegan-master | dnnlib/tflib/autosummary.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | stylegan-master | dnnlib/tflib/tfutil.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | stylegan-master | dnnlib/tflib/network.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain ... | stylegan-master | dnnlib/tflib/optimizer.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | stylegan-master | dnnlib/submission/submit.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | stylegan-master | dnnlib/submission/__init__.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | stylegan-master | dnnlib/submission/run_context.py |
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain... | stylegan-master | dnnlib/submission/_internal/run.py |
from setuptools import setup, find_packages
setup(
name = 'mlm-pytorch',
packages = find_packages(),
version = '0.1.0',
license='MIT',
description = 'MLM (Masked Language Modeling) - Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url = 'https://github.com/lucidrains/mlm-pytorch'... | mlm-pytorch-master | setup.py |
import math
from functools import reduce
import torch
from torch import nn
import torch.nn.functional as F
# helpers
def prob_mask_like(t, prob):
return torch.zeros_like(t).float().uniform_(0, 1) < prob
def mask_with_tokens(t, token_ids):
init_no_mask = torch.full_like(t, False, dtype=torch.bool)
mask =... | mlm-pytorch-master | mlm_pytorch/mlm_pytorch.py |
from mlm_pytorch.mlm_pytorch import MLM
| mlm-pytorch-master | mlm_pytorch/__init__.py |
from setuptools import setup, find_packages
setup(
name = 'adan-pytorch',
packages = find_packages(exclude=[]),
version = '0.1.0',
license='MIT',
description = 'Adan - (ADAptive Nesterov momentum algorithm) Optimizer in Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_descrip... | Adan-pytorch-main | setup.py |
import math
import torch
from torch.optim import Optimizer
def exists(val):
return val is not None
class Adan(Optimizer):
def __init__(
self,
params,
lr = 1e-3,
betas = (0.02, 0.08, 0.01),
eps = 1e-8,
weight_decay = 0,
restart_cond: callable = None
)... | Adan-pytorch-main | adan_pytorch/adan.py |
from adan_pytorch.adan import Adan
| Adan-pytorch-main | adan_pytorch/__init__.py |
from setuptools import setup, find_packages
setup(
name = 'perceiver-ar-pytorch',
packages = find_packages(exclude=[]),
version = '0.0.10',
license='MIT',
description = 'Perceiver AR',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_description_content_type = 'text/markdown',
url = ... | perceiver-ar-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 perceiver_ar_pytorch import PerceiverAR
from perceiver_ar_pytorch.autoregressive_wrapper import AutoregressiveWrapper
# constant... | perceiver-ar-pytorch-main | train.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... | perceiver-ar-pytorch-main | perceiver_ar_pytorch/autoregressive_wrapper.py |
from perceiver_ar_pytorch.perceiver_ar_pytorch import PerceiverAR
| perceiver-ar-pytorch-main | perceiver_ar_pytorch/__init__.py |
import torch
import torch.nn.functional as F
from torch import nn, einsum
from einops import rearrange, repeat
# helper functions
def exists(val):
return val is not None
# feedforward
def FeedForward(dim, mult = 4, dropout = 0.):
hidden_dim = int(dim * mult)
return nn.Sequential(
nn.LayerNorm(d... | perceiver-ar-pytorch-main | perceiver_ar_pytorch/perceiver_ar_pytorch.py |
from base import BaseTestCase
from parameterized import parameterized
#class SearchTest(BaseTestCase):
#@parameterized.expand([['@mobile_test'], ['@mobile_test_2']])
#def test_username_search(self, username):
#self.search_username(username)
#self.assert_text(f'{username}')
| nitter-master | tests/test_search.py |
from base import BaseTestCase, Timeline
from parameterized import parameterized
normal = [['jack'], ['elonmusk']]
after = [['jack', '1681686036294803456'],
['elonmusk', '1681686036294803456']]
no_more = [['mobile_test_8?cursor=1000']]
empty = [['emptyuser'], ['mobile_test_10']]
protected = [['mobile_test_... | nitter-master | tests/test_timeline.py |
from base import BaseTestCase, Profile
from parameterized import parameterized
profiles = [
['mobile_test', 'Test account',
'Test Account. test test Testing username with @mobile_test_2 and a #hashtag',
'San Francisco, CA', 'example.com/foobar', 'Joined October 2009', '98'],
['mobile_... | nitter-master | tests/test_profile.py |
from base import BaseTestCase, Conversation
from parameterized import parameterized
thread = [
['octonion/status/975253897697611777', [], 'Based', ['Crystal', 'Julia'], [
['For', 'Then', 'Okay,', 'Python', 'Speed', 'Java', 'Coding', 'I', 'You'],
['yeah,']
]],
['octonion/status/975254452625... | nitter-master | tests/test_thread.py |
from base import BaseTestCase, Card, Conversation
from parameterized import parameterized
card = [
['nim_lang/status/1136652293510717440',
'Version 0.20.0 released',
'We are very proud to announce Nim version 0.20. This is a massive release, both literally and figuratively. It contains more than 1,000 c... | nitter-master | tests/test_card.py |
from base import BaseTestCase, Quote, Conversation
from parameterized import parameterized
text = [
['elonmusk/status/1138136540096319488',
'TREV PAGE', '@Model3Owners',
"""As of March 58.4% of new car sales in Norway are electric.
What are we doing wrong? reuters.com/article/us-norwa…"""],
['nim_... | nitter-master | tests/test_quote.py |
from base import BaseTestCase, Tweet, get_timeline_tweet
from parameterized import parameterized
# image = tweet + 'div.attachments.media-body > div > div > a > div > img'
# self.assert_true(self.get_image_url(image).split('/')[0] == 'http')
timeline = [
[1, 'Test account', 'mobile_test', '10 Aug 2016', '76348357... | nitter-master | tests/test_tweet.py |
from seleniumbase import BaseCase
class Card(object):
def __init__(self, tweet=''):
card = tweet + '.card '
self.link = card + 'a'
self.title = card + '.card-title'
self.description = card + '.card-description'
self.destination = card + '.card-destination'
self.imag... | nitter-master | tests/base.py |
from base import BaseTestCase, Poll, Media
from parameterized import parameterized
from selenium.webdriver.common.by import By
poll = [
['nim_lang/status/1064219801499955200', 'Style insensitivity', '91', 1, [
('47%', 'Yay'), ('53%', 'Nay')
]],
['polls/status/1031986180622049281', 'What Tree Is Co... | nitter-master | tests/test_tweet_media.py |
import sys
from setuptools import setup, find_packages
sys.path[0:0] = ['stylegan2_pytorch']
from version import __version__
setup(
name = 'stylegan2_pytorch',
packages = find_packages(),
entry_points={
'console_scripts': [
'stylegan2_pytorch = stylegan2_pytorch.cli:main',
],
},
versio... | stylegan2-pytorch-master | setup.py |
from functools import partial
import random
import torch
import torch.nn.functional as F
def DiffAugment(x, types=[]):
for p in types:
for f in AUGMENT_FNS[p]:
x = f(x)
return x.contiguous()
# """
# Augmentation functions got images as `x`
# where `x` is tensor with this dimensions:
# 0 ... | stylegan2-pytorch-master | stylegan2_pytorch/diff_augment.py |
__version__ = '1.8.9'
| stylegan2-pytorch-master | stylegan2_pytorch/version.py |
from stylegan2_pytorch.stylegan2_pytorch import Trainer, StyleGAN2, NanException, ModelLoader
| stylegan2-pytorch-master | stylegan2_pytorch/__init__.py |
import os
import sys
import math
import fire
import json
from tqdm import tqdm
from math import floor, log2
from random import random
from shutil import rmtree
from functools import partial
import multiprocessing
from contextlib import contextmanager, ExitStack
import numpy as np
import torch
from torch import nn, e... | stylegan2-pytorch-master | stylegan2_pytorch/stylegan2_pytorch.py |
import os
import fire
import random
from retry.api import retry_call
from tqdm import tqdm
from datetime import datetime
from functools import wraps
from stylegan2_pytorch import Trainer, NanException
import torch
import torch.multiprocessing as mp
import torch.distributed as dist
import numpy as np
def cast_list(el... | stylegan2-pytorch-master | stylegan2_pytorch/cli.py |
from setuptools import setup, find_packages
setup(
name = 'bidirectional-cross-attention',
packages = find_packages(exclude=[]),
version = '0.0.4',
license='MIT',
description = 'Bidirectional Cross Attention',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url = 'https://github.com/lucidr... | bidirectional-cross-attention-main | setup.py |
import torch
from torch import nn
from einops import rearrange
from torch import einsum
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
def stable_softmax(t, dim = -1):
t = t - t.amax(dim = dim, keepdim = True)
return t.softmax(dim = dim)
# bidirectional... | bidirectional-cross-attention-main | bidirectional_cross_attention/bidirectional_cross_attention.py |
from bidirectional_cross_attention.bidirectional_cross_attention import BidirectionalCrossAttention
| bidirectional-cross-attention-main | bidirectional_cross_attention/__init__.py |
from setuptools import setup, find_packages
setup(
name = 'rela-transformer',
packages = find_packages(exclude=[]),
version = '0.0.7',
license='MIT',
description = 'ReLA Transformer',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url = 'https://github.com/lucidrains/rela-transformer',
... | rela-transformer-main | setup.py |
from rela_transformer import ReLATransformer
from rela_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
# constants
NU... | rela-transformer-main | train.py |
from functools import partial
import torch
import random
from torch import nn
import torch.nn.functional as F
from torch.nn.utils.rnn import pad_sequence
def exists(val):
return val is not None
def default(value, default):
return value if exists(value) else default
def log(t, eps=1e-9):
return torch.log(... | rela-transformer-main | rela_transformer/autoregressive_wrapper.py |
from rela_transformer.rela_transformer import ReLATransformer
| rela-transformer-main | rela_transformer/__init__.py |
import torch
import torch.nn.functional as F
from torch import nn, einsum
from einops import rearrange, repeat
# helper functions
def exists(val):
return val is not None
# classes
class GatedRMSNorm(nn.Module):
def __init__(
self,
dim,
eps = 1e-8
):
super().__init__()
... | rela-transformer-main | rela_transformer/rela_transformer.py |
from setuptools import setup, find_packages
setup(
name = 'ema-pytorch',
packages = find_packages(exclude=[]),
version = '0.2.3',
license='MIT',
description = 'Easy way to keep track of exponential moving average version of your pytorch module',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com'... | ema-pytorch-main | setup.py |
from ema_pytorch.ema_pytorch import EMA
| ema-pytorch-main | ema_pytorch/__init__.py |
import copy
import torch
from torch import nn
def exists(val):
return val is not None
def clamp(value, min_value = None, max_value = None):
assert exists(min_value) or exists(max_value)
if exists(min_value):
value = max(value, min_value)
if exists(max_value):
value = min(value, max_va... | ema-pytorch-main | ema_pytorch/ema_pytorch.py |
from setuptools import setup, find_packages
setup(
name = 'PaLM-jax',
packages = find_packages(exclude=[]),
version = '0.1.2',
license='MIT',
description = 'PaLM: Scaling Language Modeling with Pathways - Jax',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_description_content_type =... | PaLM-jax-main | setup.py |
import os
from random import randrange
from functools import partial
import tqdm
import gzip
import numpy as np
import jax
import jax.numpy as jnp
from jax import nn
import equinox as eqx
from optax import adam, clip_by_global_norm, chain, apply_every
from palm_jax.palm_lite import PaLM
from palm_jax.utils import sa... | PaLM-jax-main | train.py |
from typing import List, Tuple
import numpy as onp
from jax import random, nn, lax, jit, numpy as np
from jax.numpy import einsum
from equinox import Module, static_field
from einops import rearrange, repeat
# bias-less layernorm
class LayerNorm(Module):
gamma: np.ndarray
eps: float = static_field()
de... | PaLM-jax-main | palm_jax/palm.py |
from palm_jax.palm import PaLM
| PaLM-jax-main | palm_jax/__init__.py |
from math import log2, floor
from typing import List, Tuple
import numpy as onp
from jax import random, jit, nn, lax, numpy as np
from jax.numpy import einsum
from equinox import Module, static_field
from einops import rearrange, repeat
# rmsnorm
class RMSNorm(Module):
gamma: np.ndarray
scale: float = stati... | PaLM-jax-main | palm_jax/palm_lite.py |
from jax import random
from jax.lax import top_k
import jax.numpy as np
# helper functions
def exists(val):
return val is not None
def log(t, eps = 1e-20):
return np.log(t + eps)
# sampling functions
def select_top_k(tensor, k):
values, _ = top_k(tensor, k)
mask = tensor > values.min()
return m... | PaLM-jax-main | palm_jax/utils.py |
from setuptools import setup, find_packages
setup(
name = 'memory-efficient-attention-pytorch',
packages = find_packages(exclude=[]),
version = '0.1.6',
license='MIT',
description = 'Memory Efficient Attention - Pytorch',
long_description_content_type = 'text/markdown',
author = 'Phil Wang',
author_ema... | memory-efficient-attention-pytorch-main | setup.py |
from memory_efficient_attention_pytorch.transformer import Transformer
from memory_efficient_attention_pytorch.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... | memory-efficient-attention-pytorch-main | train.py |
import torch
from memory_efficient_attention_pytorch import Attention
from memory_efficient_attention_pytorch.memory_efficient_attention import attention
from memory_efficient_attention_pytorch.flash_attention import FlashAttention, FlashAttentionFunction
# constants
def isclose(a, b, atol = 1e-6):
diff = (a - b... | memory-efficient-attention-pytorch-main | tests/test.py |
import torch
from torch import nn
import torch.nn.functional as F
# 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, **kwargs)
model.train(was_tr... | memory-efficient-attention-pytorch-main | memory_efficient_attention_pytorch/autoregressive_wrapper.py |
import torch
from functools import partial
from torch import nn, einsum
from torch.utils.checkpoint import checkpoint
import torch.nn.functional as F
from einops import rearrange
# helper functions
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
# regular atten... | memory-efficient-attention-pytorch-main | memory_efficient_attention_pytorch/memory_efficient_attention.py |
import torch
import torch.nn as nn
from operator import itemgetter
from torch.autograd.function import Function
from torch.utils.checkpoint import get_device_states, set_device_states
# for routing arguments into the functions of the reversible layer
def route_args(router, args, depth):
routed_args = [(dict(), dic... | memory-efficient-attention-pytorch-main | memory_efficient_attention_pytorch/reversible.py |
from memory_efficient_attention_pytorch.memory_efficient_attention import Attention, memory_efficient_attention
from memory_efficient_attention_pytorch.memory_efficient_cosine_sim_attention import CosineSimAttention, numerically_unstable_memory_efficient_attention
from memory_efficient_attention_pytorch.flash_attention... | memory-efficient-attention-pytorch-main | memory_efficient_attention_pytorch/__init__.py |
import math
import torch
from functools import partial
from torch import nn, einsum
import torch.nn.functional as F
from torch.autograd.function import Function
from einops import rearrange
# constants
EPSILON = 1e-6
# helper functions
def exists(val):
return val is not None
def default(val, d):
return va... | memory-efficient-attention-pytorch-main | memory_efficient_attention_pytorch/cosine_sim_flash_attention.py |
import torch
from torch import nn, einsum
import torch.nn.functional as F
from functools import partial
from einops import rearrange
from memory_efficient_attention_pytorch import FlashAttention, Attention
from memory_efficient_attention_pytorch.reversible import ReversibleSequence
def exists(val):
return val is ... | memory-efficient-attention-pytorch-main | memory_efficient_attention_pytorch/transformer.py |
import math
import torch
from functools import partial
from torch import nn, einsum
from torch.autograd.function import Function
from einops import rearrange
# constants
EPSILON = 1e-10
# helper functions
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
# flas... | memory-efficient-attention-pytorch-main | memory_efficient_attention_pytorch/flash_attention.py |
import math
import torch
import torch.nn.functional as F
from functools import partial
from torch import nn, einsum
from torch.utils.checkpoint import checkpoint
from einops import rearrange
# helper functions
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
def... | memory-efficient-attention-pytorch-main | memory_efficient_attention_pytorch/memory_efficient_cosine_sim_attention.py |
from setuptools import setup, find_packages
setup(
name = 'tab-transformer-pytorch',
packages = find_packages(),
version = '0.2.6',
license='MIT',
description = 'Tab Transformer - Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url = 'https://github.com/lucidrains/tab-transformer... | tab-transformer-pytorch-main | setup.py |
import torch
import torch.nn.functional as F
from torch import nn, einsum
from einops import rearrange, repeat
# feedforward and attention
class GEGLU(nn.Module):
def forward(self, x):
x, gates = x.chunk(2, dim = -1)
return x * F.gelu(gates)
def FeedForward(dim, mult = 4, dropout = 0.):
retu... | tab-transformer-pytorch-main | tab_transformer_pytorch/ft_transformer.py |
from tab_transformer_pytorch.tab_transformer_pytorch import TabTransformer
from tab_transformer_pytorch.ft_transformer import FTTransformer
| tab-transformer-pytorch-main | tab_transformer_pytorch/__init__.py |
import torch
import torch.nn.functional as F
from torch import nn, einsum
from einops import rearrange
# helpers
def exists(val):
return val is not None
def default(val, d):
return val if exists(val) else d
# classes
class Residual(nn.Module):
def __init__(self, fn):
super().__init__()
... | tab-transformer-pytorch-main | tab_transformer_pytorch/tab_transformer_pytorch.py |
from setuptools import setup, find_packages
setup(
name = 'rvq-vae-gpt',
packages = find_packages(exclude=[]),
version = '0.0.4',
license='MIT',
description = 'Yet another attempt at GPT in quantized latent space',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
long_description_content_ty... | rvq-vae-gpt-main | setup.py |
import gzip
import random
import tqdm
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 rvq_vae_gpt import TextVQVAE
# constants
NUM_BATCHES = int(1e5)
BATCH_SIZE = 4
GRADIENT_ACCUMULATE_EVERY = 4
LEARNING_RATE = 1... | rvq-vae-gpt-main | train.py |
from rvq_vae_gpt.rvq_vae_gpt import TextVQVAE, Transformer
| rvq-vae-gpt-main | rvq_vae_gpt/__init__.py |
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 local_attention import LocalMHA
from vector_quantize_pytorch import VectorQuantize, ResidualVQ
from beartype import beartype
from beartype.typing... | rvq-vae-gpt-main | rvq_vae_gpt/rvq_vae_gpt.py |
import os
import sys
from distutils.core import setup
from setuptools.command.install import install
from setuptools import find_packages
# circleci.py version
VERSION = '1.2.0'
with open('README.rst', 'r') as fh:
long_description = fh.read().split('Results\n-------')[0]
with open('requirements.txt', 'r') as fh:... | memcnn-master | setup.py |
# -*- coding: utf-8 -*-
"""Top-level package for MemCNN."""
__author__ = """Sil van de Leemput"""
__email__ = 'silvandeleemput@gmail.com'
__version__ = '1.2.0'
from memcnn.models.revop import ReversibleBlock, InvertibleModuleWrapper, create_coupling, is_invertible_module
from memcnn.models.additive import AdditiveC... | memcnn-master | memcnn/__init__.py |
import argparse
import os
import logging
import torch
from memcnn.config import Config
from memcnn.experiment.manager import ExperimentManager
from memcnn.experiment.factory import load_experiment_config, experiment_config_parser
import memcnn.utils.log
logger = logging.getLogger('train')
def run_experiment(exper... | memcnn-master | memcnn/train.py |
import json
import os
class Config(dict):
def __init__(self, dic=None, verbose=False):
super(Config, self).__init__()
if dic is None:
fname = self.get_filename()
if verbose:
print("loading default {0}".format(fname))
with open(fname, "r") as f:
... | memcnn-master | memcnn/config/__init__.py |
memcnn-master | memcnn/config/tests/__init__.py | |
import unittest
import json
import os
from memcnn.experiment.factory import load_experiment_config, experiment_config_parser
from memcnn.config import Config
import memcnn.config
class ConfigTestCase(unittest.TestCase):
class ConfigTest(Config):
@staticmethod
def get_filename():
retur... | memcnn-master | memcnn/config/tests/test_config.py |
import os
import json
import logging
import sys
import time
def setup(use_stdout=True, filename=None, log_level=logging.DEBUG):
"""setup some basic logging"""
log = logging.getLogger('')
log.setLevel(log_level)
fmt = logging.Formatter("%(asctime)s [%(name)-15s] %(message)s", datefmt="%y-%m-%d %H:%M:%... | memcnn-master | memcnn/utils/log.py |
memcnn-master | memcnn/utils/__init__.py | |
import torch
import torch.nn as nn
from torch.nn.modules.module import Module
def _assert_no_grad(variable):
msg = "nn criterions don't compute the gradient w.r.t. targets - please " \
"mark these variables as not requiring gradients"
assert not variable.requires_grad, msg # nosec
class CrossEntr... | memcnn-master | memcnn/utils/loss.py |
""" Module containing utilities to compute statistics
Some bits from: https://gist.github.com/xmfbit/67c407e34cbaf56e7820f09e774e56d8
"""
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self):
self.reset()
def reset(self):
self.val = 0
... | memcnn-master | memcnn/utils/stats.py |
import pytest
import torch
from memcnn.utils.stats import AverageMeter, accuracy
@pytest.mark.parametrize('val,n', [(1, 1), (14, 10), (10, 14), (5, 1), (1, 5), (0, 10)])
def test_average_meter(val, n):
meter = AverageMeter()
assert meter.val == 0
assert meter.avg == 0
assert meter.sum == 0
assert ... | memcnn-master | memcnn/utils/tests/test_stats.py |
memcnn-master | memcnn/utils/tests/__init__.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.