repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
stellargraph
stellargraph-master/tests/layer/test_cluster_models.py
# -*- coding: utf-8 -*- # # Copyright 2020 Data61, CSIRO # # 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...
1,978
35.648148
74
py
stellargraph
stellargraph-master/tests/layer/test_attri2vec.py
# -*- coding: utf-8 -*- # # Copyright 2018-2020 Data61, CSIRO # # 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 applicabl...
5,167
27.086957
99
py
stellargraph
stellargraph-master/tests/layer/test_cluster_gcn.py
# -*- coding: utf-8 -*- # # Copyright 2018-2020 Data61, CSIRO # # 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 applicabl...
5,180
28.947977
88
py
stellargraph
stellargraph-master/tests/layer/test_rgcn.py
# -*- coding: utf-8 -*- # # Copyright 2019-2020 Data61, CSIRO # # 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 applicabl...
12,811
32.020619
88
py
stellargraph
stellargraph-master/tests/layer/test_appnp.py
# -*- coding: utf-8 -*- # # Copyright 2019-2020 Data61, CSIRO # # 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 applicabl...
10,399
32.656958
88
py
stellargraph
stellargraph-master/tests/layer/test_gcn.py
# -*- coding: utf-8 -*- # # Copyright 2018-2020 Data61, CSIRO # # 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 applicabl...
11,000
32.336364
98
py
stellargraph
stellargraph-master/tests/layer/test_node2vec.py
# -*- coding: utf-8 -*- # # Copyright 2019-2020 Data61, CSIRO # # 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 applicabl...
3,449
29.263158
74
py
stellargraph
stellargraph-master/tests/layer/test_graphsage.py
# -*- coding: utf-8 -*- # # Copyright 2018-2020 Data61, CSIRO # # 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 applicabl...
20,315
27.776204
94
py
stellargraph
stellargraph-master/tests/layer/test_graph_attention.py
# -*- coding: utf-8 -*- # # Copyright 2018-2020 Data61, CSIRO # # 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 applicabl...
20,638
31.86465
85
py
stellargraph
stellargraph-master/tests/layer/test_link_inference.py
# -*- coding: utf-8 -*- # # Copyright 2018-2020 Data61, CSIRO # # 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 applicabl...
13,763
36.606557
127
py
stellargraph
stellargraph-master/tests/layer/test_knowledge_graph.py
# -*- coding: utf-8 -*- # # Copyright 2020 Data61, CSIRO # # 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...
18,872
36.005882
106
py
stellargraph
stellargraph-master/docs/conf.py
# -*- coding: utf-8 -*- # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config import urllib.parse import docutils import sphinx # -- Path setup ---------...
12,154
33.928161
296
py
baidu_ultr_dataset
baidu_ultr_dataset-main/pretrain.py
# -*- encoding: utf-8 -*- ''' @Time : 2022/06/10 15:51:44 @Author : Chu Xiaokai @Contact : xiaokaichu@gmail.com ''' import time import sys import os sys.path.append(os.getcwd()) from dataloader import * from Transformer4Ranking.model import * import torch from torch import nn from torch.utils.data import Dat...
5,998
35.138554
132
py
baidu_ultr_dataset
baidu_ultr_dataset-main/dataloader.py
# -*- encoding: utf-8 -*- ''' @Time : 2022/06/10 15:51:44 @Author : Chu Xiaokai @Contact : xiaokaichu@gmail.com ''' import math import torch import torch.nn.functional as F import os import random from torch.utils.data import Dataset, DataLoader, IterableDataset import gzip from functools import reduce from a...
8,424
37.47032
129
py
baidu_ultr_dataset
baidu_ultr_dataset-main/unbiased_learning.py
# -*- encoding: utf-8 -*- ''' @Time : 2022/06/12 14:49:28 @Author : Chu Xiaokai @Contact : xiaokaichu@gmail.com ''' from baseline_model.utils.sys_tools import find_class import torch import numpy as np import warnings import sys from metrics import * from Transformer4Ranking.model import * from dataloader im...
4,451
37.713043
129
py
baidu_ultr_dataset
baidu_ultr_dataset-main/submit.py
#!/usr/bin/env python # coding=utf-8 # File Name: evaluate.py # Author: Lixin Zou # Mail: zoulixin15@gmail.com # Created Time: Tue Sep 13 23:21:03 2022 #### Demo submission to WSDM Cup 2023 ##### # Step 1: # Get the prediction score of model. # > ``` python submit.py --emb_dim 768 --nlayer 12 --nhead 12 --dropout 0.1 ...
2,185
32.121212
157
py
baidu_ultr_dataset
baidu_ultr_dataset-main/baseline_model/learning_algorithm/dla.py
"""Training and testing the dual learning algorithm for unbiased learning to rank. See the following paper for more information on the dual learning algorithm. * Qingyao Ai, Keping Bi, Cheng Luo, Jiafeng Guo, W. Bruce Croft. 2018. Unbiased Learning to Rank with Unbiased Propensity Estimation. In Proceedings of SI...
11,065
39.985185
165
py
baidu_ultr_dataset
baidu_ultr_dataset-main/baseline_model/learning_algorithm/ipw_rank.py
"""Training and testing the inverse propensity weighting algorithm for unbiased learning to rank. See the following paper for more information on the inverse propensity weighting algorithm. * Xuanhui Wang, Michael Bendersky, Donald Metzler, Marc Najork. 2016. Learning to Rank with Selection Bias in Personal Searc...
7,426
41.44
190
py
baidu_ultr_dataset
baidu_ultr_dataset-main/baseline_model/learning_algorithm/pairwise_debias.py
"""Training and testing the Pairwise Debiasing algorithm for unbiased learning to rank. See the following paper for more information on the Pairwise Debiasing algorithm. * Hu, Ziniu, Yang Wang, Qu Peng, and Hang Li. "Unbiased LambdaMART: An Unbiased Pairwise Learning-to-Rank Algorithm." In The World Wide Web Conf...
7,675
41.644444
181
py
baidu_ultr_dataset
baidu_ultr_dataset-main/baseline_model/learning_algorithm/base_algorithm.py
"""The basic class that contains all the API needed for the implementation of an unbiased learning to rank algorithm. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function from matplotlib.cbook import print_cycles import torch.nn.functional as F import torc...
8,278
38.802885
124
py
baidu_ultr_dataset
baidu_ultr_dataset-main/baseline_model/learning_algorithm/regression_EM.py
"""Training and testing the regression-based EM algorithm for unbiased learning to rank. See the following paper for more information on the regression-based EM algorithm. * Wang, Xuanhui, Nadav Golbandi, Michael Bendersky, Donald Metzler, and Marc Najork. "Position bias estimation for unbiased learning to rank i...
7,819
42.687151
280
py
baidu_ultr_dataset
baidu_ultr_dataset-main/baseline_model/learning_algorithm/navie_algorithm.py
"""The navie algorithm that directly trains ranking models with clicks. """ from __future__ import absolute_import from __future__ import division from __future__ import print_function import torch import torch.nn as nn from baseline_model.learning_algorithm.base_algorithm import BaseAlgorithm import baseline_mode...
4,950
37.084615
102
py
baidu_ultr_dataset
baidu_ultr_dataset-main/Transformer4Ranking/model.py
# -*- encoding: utf-8 -*- ''' @Time : 2022/06/10 15:51:44 @Author : Chu Xiaokai @Contact : xiaokaichu@gmail.com ''' import math import torch from torch import nn, Tensor import torch.nn.functional as F from torch.nn import TransformerEncoder, TransformerEncoderLayer from torch.optim.lr_scheduler import Lambda...
4,708
37.284553
114
py
DaVinci
DaVinci-main/VE.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. import argparse import os import ruamel.yaml as yaml import numpy as np import random import tim...
10,713
40.366795
136
py
DaVinci
DaVinci-main/NLVR.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. import argparse import os import ruamel.yaml as yaml import numpy as np import random import tim...
9,857
39.904564
136
py
DaVinci
DaVinci-main/glue.py
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. team. All rights reserved. # # 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 r...
25,935
42.443886
136
py
DaVinci
DaVinci-main/utils.py
import numpy as np import io import os import time from collections import defaultdict, deque import datetime import torch import torch.distributed as dist class SmoothedValue(object): """Track a series of values and provide access to smoothed values over a window or the global series average. """ d...
8,166
29.136531
94
py
DaVinci
DaVinci-main/image_finetune.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. import argparse import builtins import os import random import shutil import time import warning...
27,204
39.665172
140
py
DaVinci
DaVinci-main/image_sampling.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. import argparse import os import sys import ruamel.yaml as yaml import numpy as np import random...
9,275
38.305085
172
py
DaVinci
DaVinci-main/gen_coco.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. import argparse import os, sys import ruamel.yaml as yaml import numpy as np import random impor...
10,773
41.25098
166
py
DaVinci
DaVinci-main/Pretrain.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. import argparse import os import sys import ruamel.yaml as yaml import numpy as np import rando...
14,283
45.832787
218
py
DaVinci
DaVinci-main/image_linprobe.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. #!/usr/bin/env python import argparse import builtins import os import random import shutil imp...
25,791
39.489796
169
py
DaVinci
DaVinci-main/VQA.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. import argparse import os, sys import ruamel.yaml as yaml import numpy as np import random impor...
10,600
40.901186
140
py
DaVinci
DaVinci-main/scheduler/plateau_lr.py
""" Plateau Scheduler Adapts PyTorch plateau scheduler and allows application of noise, warmup. Hacked together by / Copyright 2020 Ross Wightman """ import torch from .scheduler import Scheduler class PlateauLRScheduler(Scheduler): """Decay the LR by a factor every time the validation loss plateaus.""" d...
4,140
35.324561
97
py
DaVinci
DaVinci-main/scheduler/tanh_lr.py
""" TanH Scheduler TanH schedule with warmup, cycle/restarts, noise. Hacked together by / Copyright 2020 Ross Wightman """ import logging import math import numpy as np import torch from .scheduler import Scheduler _logger = logging.getLogger(__name__) class TanhLRScheduler(Scheduler): """ Hyberbolic-Tan...
4,045
32.438017
106
py
DaVinci
DaVinci-main/scheduler/cosine_lr.py
""" Cosine Scheduler Cosine LR schedule with warmup, cycle/restarts, noise. Hacked together by / Copyright 2020 Ross Wightman """ import logging import math import numpy as np import torch from .scheduler import Scheduler from pdb import set_trace as breakpoint _logger = logging.getLogger(__name__) class CosineL...
4,027
33.135593
121
py
DaVinci
DaVinci-main/scheduler/scheduler.py
from typing import Dict, Any import torch class Scheduler: """ Parameter Scheduler Base Class A scheduler base class that can be used to schedule any optimizer parameter groups. Unlike the builtin PyTorch schedulers, this is intended to be consistently called * At the END of each epoch, before incre...
4,750
43.820755
112
py
DaVinci
DaVinci-main/scheduler/step_lr.py
""" Step Scheduler Basic step LR schedule with warmup, noise. Hacked together by / Copyright 2020 Ross Wightman """ import math import torch from .scheduler import Scheduler class StepLRScheduler(Scheduler): """ """ def __init__(self, optimizer: torch.optim.Optimizer, ...
1,902
28.734375
105
py
DaVinci
DaVinci-main/scheduler/scheduler_factory.py
""" Scheduler Factory Hacked together by / Copyright 2020 Ross Wightman """ from .cosine_lr import CosineLRScheduler from .tanh_lr import TanhLRScheduler from .step_lr import StepLRScheduler from .plateau_lr import PlateauLRScheduler from torch.optim.lr_scheduler import LambdaLR def create_scheduler(args, optimizer):...
4,603
39.034783
131
py
DaVinci
DaVinci-main/dataset/dalle_transforms.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
6,719
35.923077
118
py
DaVinci
DaVinci-main/dataset/nlvr_dataset.py
import json import os from torch.utils.data import Dataset from PIL import Image from dataset.utils import pre_caption class nlvr_dataset(Dataset): def __init__(self, ann_file, transform, image_root): self.ann = [] for f in ann_file: self.ann += json.load(open(f,'r')) s...
1,158
27.975
82
py
DaVinci
DaVinci-main/dataset/utils.py
import re def pre_question(question,max_ques_words): question = re.sub( r"([,.'!?\"()*#:;~])", '', question.lower(), ).replace('-', ' ').replace('/', ' ') question = question.rstrip(' ') #truncate question question_words = question.split(' ') if len(question_words...
5,225
30.865854
118
py
DaVinci
DaVinci-main/dataset/vqa_dataset.py
import os import json import random from PIL import Image from torch.utils.data import Dataset from dataset.utils import pre_question from collections import Counter class vqa_dataset(Dataset): def __init__(self, ann_file, transform, vqa_root, vg_root, eos='[SEP]', split="train", max_ques_words=30, answer_list='./...
2,702
36.541667
153
py
DaVinci
DaVinci-main/dataset/dist_dataset.py
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from typing import List, Any import warnings import random from itertools import cycle import torch from torch.utils.data import IterableDataset from util.hdfs_io import hopen, hlist_files class DistLineReadingDataset(IterableDataset): # pylint: disable=W0223...
3,304
35.318681
113
py
DaVinci
DaVinci-main/dataset/ve_dataset.py
import json import os from torch.utils.data import Dataset from PIL import Image from dataset.utils import pre_caption class ve_dataset(Dataset): def __init__(self, ann_file, transform, image_root, max_words=30): self.ann = json.load(open(ann_file,'r')) self.transform = transform s...
919
28.677419
80
py
DaVinci
DaVinci-main/dataset/caption_dataset.py
import json import os import random from torch.utils.data import Dataset from PIL import Image from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True Image.MAX_IMAGE_PIXELS = None from dataset.utils import pre_caption from dataset.dist_dataset import DistLineReadingDataset import traceback from base64 impo...
8,210
31.713147
129
py
DaVinci
DaVinci-main/dataset/__init__.py
import torch from torch.utils.data import DataLoader from torchvision import transforms from dataset.dalle_transforms import RandomResizedCropAndInterpolationWithTwoPic from PIL import Image from timm.data.constants import \ IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, IMAGENET_INCEPTION_MEAN, IMAGENET_INCEPTION_ST...
7,913
49.088608
166
py
DaVinci
DaVinci-main/dataset/gen_dataset.py
import json import os from torch.utils.data import Dataset from PIL import Image from dataset.utils import pre_caption class gen_dataset(Dataset): def __init__(self, ann_file, transform, image_root, split='train', max_words=30, prompt=''): self.ann = json.load(open(ann_file,'r')) self.transform =...
1,228
31.342105
97
py
DaVinci
DaVinci-main/models/bert.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
82,267
41.870245
213
py
DaVinci
DaVinci-main/models/model_vqa.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. from models.davinci_pretrain import DaVinci import torch from torch import nn import torch.nn.f...
1,496
33.813953
114
py
DaVinci
DaVinci-main/models/resnet.py
from typing import Type, Any, Callable, Union, List, Optional import torch import torch.nn as nn from torch import Tensor from timm.models.layers import trunc_normal_, DropPath # from .._internally_replaced_utils import load_state_dict_from_url try: from torch.hub import load_state_dict_from_url # noqa: 401 exc...
25,975
39.148377
118
py
DaVinci
DaVinci-main/models/xbert.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # 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 cop...
99,022
43.029791
213
py
DaVinci
DaVinci-main/models/vit.py
import torch import torch.nn as nn import torch.nn.functional as F from functools import partial from timm.models.vision_transformer import _cfg, PatchEmbed from timm.models.registry import register_model from timm.models.layers import trunc_normal_, DropPath class Mlp(nn.Module): """ MLP as used in Vision Trans...
8,772
42.216749
120
py
DaVinci
DaVinci-main/models/model_nlvr.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. from models.xbert import BertConfig, BertModel from models.davinci_pretrain import DaVinci impo...
2,167
38.418182
114
py
DaVinci
DaVinci-main/models/davinci_pretrain.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. from models.xbert import BertConfig, BertModelImage from models.bert import BertLMHeadModel from...
42,974
48.453395
302
py
DaVinci
DaVinci-main/models/model_linearprobe.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. from models.davinci_pretrain import DaVinci from torch import nn class DaVinciLinearProbe(nn.Mo...
1,617
43.944444
114
py
DaVinci
DaVinci-main/models/model_imageft.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. from models.davinci_pretrain import DaVinci from torch import nn class DaVinciImageFT(nn.Module...
1,713
44.105263
121
py
DaVinci
DaVinci-main/models/dalle_utils.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
19,190
33.829401
128
py
DaVinci
DaVinci-main/models/model_glue.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. from models.xbert import BertConfig from models.davinci_pretrain import DaVinci from torch impo...
1,967
39.163265
114
py
DaVinci
DaVinci-main/models/modeling_discrete_vae.py
# -------------------------------------------------------- # BEIT: BERT Pre-Training of Image Transformers (https://arxiv.org/abs/2106.08254) # Github source: https://github.com/microsoft/unilm/tree/master/beit # Copyright (c) 2021 Microsoft # Licensed under The MIT License [see LICENSE for details] # By Hangbo Bao # B...
7,573
30.823529
130
py
DaVinci
DaVinci-main/models/model_image_sampling.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. from models.xbert import BertConfig, BertModelImage from models.bert import BertLMHeadModel from...
39,775
46.522103
309
py
DaVinci
DaVinci-main/models/model_ve.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. from models.xbert import BertConfig, BertModel from models.davinci_pretrain import DaVinci from...
1,853
39.304348
114
py
DaVinci
DaVinci-main/models/dall_e/utils.py
import attr import math import torch import torch.nn as nn import torch.nn.functional as F logit_laplace_eps: float = 0.1 @attr.s(eq=False) class Conv2d(nn.Module): n_in: int = attr.ib(validator=lambda i, a, x: x >= 1) n_out: int = attr.ib(validator=lambda i, a, x: x >= 1) kw: int = attr.ib(validator=lambda i...
1,771
29.551724
81
py
DaVinci
DaVinci-main/models/dall_e/encoder.py
import attr import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from collections import OrderedDict from functools import partial from models.dall_e.utils import Conv2d @attr.s(eq=False, repr=False) class EncoderBlock(nn.Module): n_in: int = attr.ib(validator=lambda i, a, x...
3,782
39.244681
117
py
DaVinci
DaVinci-main/models/dall_e/decoder.py
import attr import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from collections import OrderedDict from functools import partial from models.dall_e.utils import Conv2d @attr.s(eq=False, repr=False) class DecoderBlock(nn.Module): n_in: int = attr.ib(validator=lambda i, a, x...
3,943
40.515789
117
py
DaVinci
DaVinci-main/models/dall_e/__init__.py
import io, requests import torch import torch.nn as nn from models.dall_e.encoder import Encoder from models.dall_e.decoder import Decoder from models.dall_e.utils import map_pixels, unmap_pixels def load_model(path: str, device: torch.device = None) -> nn.Module: if path.startswith('http://') or path.startswit...
616
31.473684
68
py
DaVinci
DaVinci-main/models/dalle_pytorch/reversible.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...
5,390
33.120253
165
py
DaVinci
DaVinci-main/models/dalle_pytorch/dalle_pytorch.py
from math import log2, sqrt import torch from torch import nn, einsum import torch.nn.functional as F import numpy as np from axial_positional_embedding import AxialPositionalEmbedding from einops import rearrange from models.dalle_pytorch import distributed_utils from models.dalle_pytorch.vae import OpenAIDiscreteVA...
21,183
33.501629
170
py
DaVinci
DaVinci-main/models/dalle_pytorch/vae.py
import io import sys import os import requests import PIL import warnings import hashlib import urllib import yaml from pathlib import Path from tqdm import tqdm from math import sqrt, log from omegaconf import OmegaConf from taming.models.vqgan import VQModel, GumbelVQ import importlib import torch from torch import ...
7,302
32.045249
111
py
DaVinci
DaVinci-main/models/dalle_pytorch/distributed_utils.py
""" Utility functions for optional distributed execution. To use, 1. set the `BACKENDS` to the ones you want to make available, 2. in the script, wrap the argument parser with `wrap_arg_parser`, 3. in the script, set and use the backend by calling `set_backend_from_args`. You can check whether a backend is in use ...
2,846
28.350515
79
py
DaVinci
DaVinci-main/models/dalle_pytorch/transformer.py
from functools import partial from itertools import islice, cycle import torch from torch import nn, einsum import torch.nn.functional as F from einops import rearrange from models.dalle_pytorch.reversible import ReversibleSequence, SequentialSequence from models.dalle_pytorch.attention import Attention, SparseAttent...
8,295
34.758621
180
py
DaVinci
DaVinci-main/models/dalle_pytorch/tokenizer.py
# take from https://github.com/openai/CLIP/blob/main/clip/simple_tokenizer.py # to give users a quick easy start to training DALL-E without doing BPE import torch import youtokentome as yttm from tokenizers import Tokenizer from tokenizers.processors import ByteLevel from transformers import BertTokenizer import htm...
9,420
34.284644
120
py
DaVinci
DaVinci-main/models/dalle_pytorch/__init__.py
from models.dalle_pytorch.dalle_pytorch import DALLE, CLIP, DiscreteVAE from models.dalle_pytorch.vae import OpenAIDiscreteVAE, VQGanVAE from pkg_resources import get_distribution # __version__ = get_distribution('dalle_pytorch').version
239
39
71
py
DaVinci
DaVinci-main/models/dalle_pytorch/attention.py
from inspect import isfunction from math import ceil import torch from torch import nn, einsum import torch.nn.functional as F from einops import rearrange, repeat from rotary_embedding_torch import apply_rotary_emb # helpers def exists(val): return val is not None def uniq(arr): return{el: True for el in ...
13,544
34.181818
165
py
DaVinci
DaVinci-main/models/dalle_pytorch/loader.py
from pathlib import Path from random import randint, choice import PIL from torch.utils.data import Dataset from torchvision import transforms as T class TextImageDataset(Dataset): def __init__(self, folder, text_len=256, image_size=128, trunca...
3,456
33.57
112
py
DaVinci
DaVinci-main/models/dalle_pytorch/distributed_backends/deepspeed_backend.py
import json import os import torch from .distributed_backend import DistributedBackend class DeepSpeedBackend(DistributedBackend): """Distributed backend using the DeepSpeed engine.""" BACKEND_MODULE_NAME = 'deepspeed' BACKEND_NAME = 'DeepSpeed' def wrap_arg_parser(self, parser): if not se...
5,987
33.813953
78
py
DaVinci
DaVinci-main/models/dalle_pytorch/distributed_backends/horovod_backend.py
import torch from .distributed_backend import DistributedBackend class HorovodBackend(DistributedBackend): """Distributed backend using Horovod.""" BACKEND_MODULE_NAME = 'horovod.torch' BACKEND_NAME = 'Horovod' def wrap_arg_parser(self, parser): return parser def check_batch_size(self,...
1,703
27.881356
71
py
DaVinci
DaVinci-main/models/DALLE-pytorch/train_dalle.py
import argparse from pathlib import Path import time from glob import glob import os import shutil import torch import wandb # Quit early if user doesn't have wandb installed. from torch.nn.utils import clip_grad_norm_ from torch.optim import Adam from torch.optim.lr_scheduler import ReduceLROnPlateau from torch.util...
22,831
33.333835
199
py
DaVinci
DaVinci-main/models/DALLE-pytorch/setup.py
from setuptools import setup, find_packages setup( name = 'dalle-pytorch', packages = find_packages(), include_package_data = True, version = '1.2.1', license='MIT', description = 'DALL-E - Pytorch', author = 'Phil Wang', author_email = 'lucidrains@gmail.com', url = 'https://github.com/lucidrains/dal...
1,052
22.4
65
py
DaVinci
DaVinci-main/models/DALLE-pytorch/generate.py
import argparse from pathlib import Path from tqdm import tqdm # torch import torch from einops import repeat # vision imports from PIL import Image from torchvision.utils import make_grid, save_image # dalle related classes and utils from dalle_pytorch import DiscreteVAE, OpenAIDiscreteVAE, VQGanVAE, DALLE from...
4,657
31.573427
286
py
DaVinci
DaVinci-main/models/DALLE-pytorch/train_vae.py
import math from math import sqrt import argparse from pathlib import Path # torch import torch from torch.optim import Adam from torch.optim.lr_scheduler import ExponentialLR # vision imports from torchvision import transforms as T from torch.utils.data import DataLoader from torchvision.datasets import ImageFolde...
9,491
29.037975
168
py
DaVinci
DaVinci-main/util/checkpointer.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. from typing import Union, Dict, List, Tuple, Any, Callable import logging import os import re im...
7,516
44.283133
114
py
DaVinci
DaVinci-main/util/torch_io.py
# Write and Paint: Generative Vision-Language Models are Unified Modal Learners (https://arxiv.org/abs/2206.07699) # Github: https://github.com/shizhediao/DaVinci # Copyright (c) 2023, ByteDance Inc. # All rights reserved. #!/usr/bin/env python # -*- coding: utf-8 -*- ''' torch model hdfs io warpper ''' import io imp...
943
26.764706
114
py
DaVinci
DaVinci-main/optim/adahessian.py
""" AdaHessian Optimizer Lifted from https://github.com/davda54/ada-hessian/blob/master/ada_hessian.py Originally licensed MIT, Copyright 2020, David Samuel """ import torch class Adahessian(torch.optim.Optimizer): """ Implements the AdaHessian algorithm from "ADAHESSIAN: An Adaptive Second OrderOptimizer fo...
6,535
40.630573
129
py
DaVinci
DaVinci-main/optim/radam.py
"""RAdam Optimizer. Implementation lifted from: https://github.com/LiyuanLucasLiu/RAdam Paper: `On the Variance of the Adaptive Learning Rate and Beyond` - https://arxiv.org/abs/1908.03265 """ import math import torch from torch.optim.optimizer import Optimizer, required class RAdam(Optimizer): def __init__(self...
5,924
37.72549
111
py
DaVinci
DaVinci-main/optim/nvnovograd.py
""" Nvidia NovoGrad Optimizer. Original impl by Nvidia from Jasper example: - https://github.com/NVIDIA/DeepLearningExamples/blob/master/PyTorch/SpeechRecognition/Jasper Paper: `Stochastic Gradient Methods with Layer-wise Adaptive Moments for Training of Deep Networks` - https://arxiv.org/abs/1905.11286 """ im...
4,795
39.302521
99
py
DaVinci
DaVinci-main/optim/adamp.py
""" AdamP Optimizer Implementation copied from https://github.com/clovaai/AdamP/blob/master/adamp/adamp.py Paper: `Slowing Down the Weight Norm Increase in Momentum-based Optimizers` - https://arxiv.org/abs/2006.08217 Code: https://github.com/clovaai/AdamP Copyright (c) 2020-present NAVER Corp. MIT license """ impor...
3,689
33.166667
123
py
DaVinci
DaVinci-main/optim/nadam.py
import torch from torch.optim import Optimizer class Nadam(Optimizer): """Implements Nadam algorithm (a variant of Adam based on Nesterov momentum). It has been proposed in `Incorporating Nesterov Momentum into Adam`__. Arguments: params (iterable): iterable of parameters to optimize or dicts de...
3,758
41.235955
108
py
DaVinci
DaVinci-main/optim/adamw.py
""" AdamW Optimizer Impl copied from PyTorch master """ import math import torch from torch.optim.optimizer import Optimizer class AdamW(Optimizer): r"""Implements AdamW algorithm. The original Adam algorithm was proposed in `Adam: A Method for Stochastic Optimization`_. The AdamW variant was proposed in...
4,965
41.084746
116
py
DaVinci
DaVinci-main/optim/adafactor.py
""" Adafactor Optimizer Lifted from https://github.com/pytorch/fairseq/blob/master/fairseq/optim/adafactor.py Original header/copyright below. """ # 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...
8,126
45.706897
114
py
DaVinci
DaVinci-main/optim/rmsprop_tf.py
""" RMSProp modified to behave like Tensorflow impl Originally cut & paste from PyTorch RMSProp https://github.com/pytorch/pytorch/blob/063946d2b3f3f1e953a2a3b54e0b34f1393de295/torch/optim/rmsprop.py Licensed under BSD-Clause 3 (ish), https://github.com/pytorch/pytorch/blob/master/LICENSE Modifications Copyright 2020...
6,127
43.729927
117
py
DaVinci
DaVinci-main/optim/novograd.py
"""NovoGrad Optimizer. Original impl by Masashi Kimura (Convergence Lab): https://github.com/convergence-lab/novograd Paper: `Stochastic Gradient Methods with Layer-wise Adaptive Moments for Training of Deep Networks` - https://arxiv.org/abs/1905.11286 """ import torch from torch.optim.optimizer import Optimizer i...
2,925
36.512821
107
py
DaVinci
DaVinci-main/optim/sgdp.py
""" SGDP Optimizer Implementation copied from https://github.com/clovaai/AdamP/blob/master/adamp/sgdp.py Paper: `Slowing Down the Weight Norm Increase in Momentum-based Optimizers` - https://arxiv.org/abs/2006.08217 Code: https://github.com/clovaai/AdamP Copyright (c) 2020-present NAVER Corp. MIT license """ import ...
3,231
32.319588
115
py
DaVinci
DaVinci-main/optim/lars.py
# Copyright (c) Meta Platforms, Inc. and affiliates. # All rights reserved. # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # -------------------------------------------------------- # LARS optimizer, implementation from MoCo v3: # https://github....
1,851
38.404255
113
py
DaVinci
DaVinci-main/optim/lookahead.py
""" Lookahead Optimizer Wrapper. Implementation modified from: https://github.com/alphadl/lookahead.pytorch Paper: `Lookahead Optimizer: k steps forward, 1 step back` - https://arxiv.org/abs/1907.08610 Hacked together by / Copyright 2020 Ross Wightman """ import torch from torch.optim.optimizer import Optimizer from c...
3,815
40.032258
93
py
DaVinci
DaVinci-main/optim/optim_factory.py
""" Optimizer Factory w/ Custom Weight Decay Hacked together by / Copyright 2020 Ross Wightman """ import torch from torch import optim as optim from .adafactor import Adafactor from .adahessian import Adahessian from .adamp import AdamP from .lookahead import Lookahead from .nadam import Nadam from .novograd import N...
4,764
37.739837
100
py
DaVinci
DaVinci-main/accelerators/accelerator.py
# -*- coding: utf-8 -*- ''' Created on Feb-19-21 16:36 accelerator.py Description: accelerators的基类,便于后续其他加速方案的接入。 ''' from logging import Logger import torch from torch.optim import Optimizer Net = torch.nn.Module class Accelerator: """ Accelerator是所有accelerators的基类,新添加的accelerator需要继承该类。 """ def ...
1,012
24.974359
98
py
DaVinci
DaVinci-main/accelerators/apex_ddp_accelerator.py
# -*- coding: utf-8 -*- ''' Created on Nov-18-20 15:21 ddp_accelerator.py @author: liuzhen.nlp Description: ''' import os import random import sys from typing import Tuple, Union, Optional, Any import numpy as np import torch import torch.distributed as distributed from torch.optim import Optimizer from torch.optim.l...
4,241
34.35
110
py
DaVinci
DaVinci-main/taming/main.py
import argparse, os, sys, datetime, glob, importlib from omegaconf import OmegaConf import numpy as np from PIL import Image import torch import torchvision from torch.utils.data import random_split, DataLoader, Dataset import pytorch_lightning as pl from pytorch_lightning import seed_everything from pytorch_lightning....
21,114
35.217839
138
py
DaVinci
DaVinci-main/taming/modules/util.py
import torch import torch.nn as nn def count_params(model): total_params = sum(p.numel() for p in model.parameters()) return total_params class ActNorm(nn.Module): def __init__(self, num_features, logdet=False, affine=True, allow_reverse_init=False): assert affine super(...
3,847
28.374046
85
py