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 |
|---|---|---|---|---|---|---|
TURL-release_ongoing | TURL-release_ongoing/data_loader/data_loaders.py | from torch.utils.data import Dataset, DataLoader, Subset
from torch.utils.data.dataloader import default_collate
from torch.utils.data.sampler import Sampler
import torch
import torch.nn as nn
import torch.nn.functional as F
from base import BaseDataLoader
import pickle
import numpy as np
import json
import os
from tqd... | 54,537 | 52.521099 | 282 | py |
TURL-release_ongoing | TURL-release_ongoing/data_loader/RE_data_loaders.py | from torch.utils.data import Dataset, DataLoader, Subset
from torch.utils.data.dataloader import default_collate
from torch.utils.data.sampler import Sampler
import torch
import torch.nn as nn
import torch.nn.functional as F
from base import BaseDataLoader
import pickle
import numpy as np
import json
import os
from tqd... | 20,775 | 46.32574 | 180 | py |
TURL-release_ongoing | TURL-release_ongoing/data_loader/CT_SemCol_data_loaders.py | from torch.utils.data import Dataset, DataLoader, Subset
from torch.utils.data.dataloader import default_collate
from torch.utils.data.sampler import Sampler
import torch
import torch.nn as nn
import torch.nn.functional as F
from base import BaseDataLoader
import pickle
import numpy as np
import json
import os
from tqd... | 13,591 | 48.068592 | 194 | py |
TURL-release_ongoing | TURL-release_ongoing/data_loader/EL_data_loaders.py | from torch.utils.data import Dataset, DataLoader, Subset
from torch.utils.data.dataloader import default_collate
from torch.utils.data.sampler import Sampler
import torch
import torch.nn as nn
import torch.nn.functional as F
from base import BaseDataLoader
import pickle
import numpy as np
import json
import os
from tqd... | 16,770 | 49.821212 | 224 | py |
TURL-release_ongoing | TURL-release_ongoing/data_loader/CT_Wiki_data_loaders.py | from torch.utils.data import Dataset, DataLoader, Subset
from torch.utils.data.dataloader import default_collate
from torch.utils.data.sampler import Sampler
import torch
import torch.nn as nn
import torch.nn.functional as F
from base import BaseDataLoader
import pickle
import numpy as np
import json
import os
from tqd... | 14,930 | 48.77 | 180 | py |
TURL-release_ongoing | TURL-release_ongoing/data_loader/hybrid_data_loaders.py | from torch.utils.data import Dataset, DataLoader, Subset
from torch.utils.data.dataloader import default_collate
from torch.utils.data.sampler import Sampler
import torch
import torch.nn as nn
import torch.nn.functional as F
from base import BaseDataLoader
import pickle
import numpy as np
import json
import os
from tqd... | 50,519 | 53.913043 | 366 | py |
TURL-release_ongoing | TURL-release_ongoing/data_loader/header_data_loaders.py | from torch.utils.data import Dataset, DataLoader, Subset
from torch.utils.data.dataloader import default_collate
from torch.utils.data.sampler import Sampler
import torch
import torch.nn as nn
import torch.nn.functional as F
from base import BaseDataLoader
import pickle
import numpy as np
import json
import os
from tqd... | 8,722 | 41.55122 | 219 | py |
TURL-release_ongoing | TURL-release_ongoing/data_loader/TR_data_loaders.py | from torch.utils.data import Dataset, DataLoader, Subset
from torch.utils.data.dataloader import default_collate
from torch.utils.data.sampler import Sampler
import torch
import torch.nn as nn
import torch.nn.functional as F
from base import BaseDataLoader
import pickle
import numpy as np
import json
import os
from tqd... | 27,563 | 50.617978 | 205 | py |
TURL-release_ongoing | TURL-release_ongoing/logger/visualization.py | import importlib
from datetime import datetime
class TensorboardWriter():
def __init__(self, log_dir, logger, enabled):
self.writer = None
self.selected_module = ""
if enabled:
log_dir = str(log_dir)
# Retrieve vizualization writer.
succeeded = False
... | 2,892 | 38.094595 | 120 | py |
TURL-release_ongoing | TURL-release_ongoing/base/base_model.py | import torch.nn as nn
import numpy as np
from abc import abstractmethod
class BaseModel(nn.Module):
"""
Base class for all models
"""
@abstractmethod
def forward(self, *inputs):
"""
Forward pass logic
:return: Model output
"""
raise NotImplementedError
... | 648 | 23.961538 | 79 | py |
TURL-release_ongoing | TURL-release_ongoing/base/base_trainer.py | import torch
from abc import abstractmethod
from numpy import inf
from logger import TensorboardWriter
class BaseTrainer:
"""
Base class for all trainers
"""
def __init__(self, model, criterion, metric_ftns, optimizer, config):
self.config = config
self.logger = config.get_logger('trai... | 7,004 | 39.726744 | 117 | py |
TURL-release_ongoing | TURL-release_ongoing/base/base_data_loader.py | import numpy as np
from torch.utils.data import DataLoader
from torch.utils.data.dataloader import default_collate
from torch.utils.data.sampler import SubsetRandomSampler
class BaseDataLoader(DataLoader):
"""
Base class for all data loaders
"""
def __init__(self, dataset, batch_size, shuffle, validat... | 1,970 | 30.790323 | 112 | py |
TURL-release_ongoing | TURL-release_ongoing/utils/prepare_entity_embedding_from_lm.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import os
import pickle
from transformers import BertTokenizer
import pdb
from tqdm import tqdm
RESERVED_ENT_VOCAB = {0:{'wiki_id':'[PAD]'},
1:{'wiki_id':'[ENT_MASK]'},
2:{'... | 3,584 | 40.206897 | 133 | py |
TURL-release_ongoing | TURL-release_ongoing/utils/prepare_header_embedding_from_pretrain.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import os
import pickle
from transformers import BertTokenizer
import pdb
from tqdm import tqdm
RESERVED_HEADER_VOCAB = {0:'[PAD]',
1:'[MASK]'}
def load_header_vocab(data_dir):
header_voca... | 3,140 | 37.777778 | 107 | py |
TURL-release_ongoing | TURL-release_ongoing/model/optim.py | """
AllenNLP just uses
`PyTorch optimizers <https://pytorch.org/docs/master/optim.html>`_ ,
with a thin wrapper to allow registering them and instantiating them `from_params`.
The available optimizers are
* `"adadelta" <https://pytorch.org/docs/master/optim.html#torch.optim.Adadelta>`_
* `"adagrad" <https://pytorch.org... | 6,401 | 42.849315 | 98 | py |
TURL-release_ongoing | TURL-release_ongoing/model/loss.py | import torch.nn.functional as F
def nll_loss(output, target):
return F.nll_loss(output, target)
| 102 | 16.166667 | 37 | py |
TURL-release_ongoing | TURL-release_ongoing/model/model.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... | 69,882 | 51.622741 | 276 | py |
TURL-release_ongoing | TURL-release_ongoing/model/metric.py | import torch
import pdb
def accuracy(output, target, ignore_index=None):
with torch.no_grad():
pred = torch.argmax(output, dim=1)
assert pred.shape[0] == len(target)
correct = 0
if ignore_index is None:
total_valid = float(len(target))
correct += torch.sum((... | 2,711 | 42.741935 | 123 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_encoder_decoder.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 15,827 | 49.893891 | 472 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/optimization.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
#
# 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/LICEN... | 8,255 | 44.866667 | 134 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/__main__.py | # coding: utf8
def main():
import sys
if (len(sys.argv) < 4 or len(sys.argv) > 6) or sys.argv[1] not in ["bert", "gpt", "transfo_xl", "gpt2", "xlnet", "xlm"]:
print(
"This command line utility let you convert original (author released) model checkpoint to pytorch.\n"
"It should be used a... | 7,085 | 53.507692 | 135 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/configuration_utils.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... | 10,830 | 50.822967 | 296 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_pytorch_utils.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... | 12,356 | 41.610345 | 166 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_distilbert.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team, The Google AI Language Team and Facebook, Inc.
#
# 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... | 39,452 | 49.710797 | 201 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_gpt2.py | # coding=utf-8
# Copyright 2018 The OpenAI Team Authors and 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 copy of the License... | 32,228 | 49.834385 | 193 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_transfo_xl.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 36,425 | 45.820051 | 193 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_auto.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 36,704 | 70.970588 | 472 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_utils.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... | 44,706 | 51.596471 | 472 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_openai.py | # coding=utf-8
# Copyright 2018 The OpenAI Team Authors and 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 copy of the License... | 30,118 | 49.535235 | 193 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_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... | 68,069 | 52.262911 | 187 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_gpt2.py | # coding=utf-8
# Copyright 2018 The OpenAI Team Authors and 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 copy of the License... | 34,421 | 49.920118 | 148 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_openai.py | # coding=utf-8
# Copyright 2018 The OpenAI Team Authors and 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 copy of the License... | 31,203 | 48.687898 | 148 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/convert_gpt2_original_tf_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 3,074 | 39.460526 | 111 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_roberta.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... | 22,329 | 51.789598 | 193 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/convert_roberta_original_pytorch_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 8,486 | 45.889503 | 188 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tokenization_bert.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
#
# 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/LICEN... | 22,451 | 43.636183 | 183 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/convert_transfo_xl_original_tf_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 5,518 | 45.771186 | 121 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/configuration_ctrl.py | # coding=utf-8
# Copyright 2018 Salesforce and 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 copy of the License at
#
# htt... | 5,775 | 39.111111 | 120 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_transfo_xl_utilities.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 8,325 | 46.306818 | 110 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_xlnet.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 57,790 | 50.92363 | 193 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/convert_openai_original_tf_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 3,161 | 40.605263 | 118 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_camembert.py | # coding=utf-8
# Copyright 2019 Inria, Facebook AI Research 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 copy of the... | 17,760 | 59.411565 | 217 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/convert_xlm_original_pytorch_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 3,235 | 37.52381 | 117 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_xlm.py | # coding=utf-8
# Copyright 2019-present, Facebook, Inc and the HuggingFace Inc. team.
#
# 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
#
# Un... | 39,276 | 49.942931 | 193 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_beam_search.py | # coding=utf-8
# Copyright (c) 2019 Yang Liu
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publi... | 10,385 | 37.183824 | 100 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/file_utils.py | """
Utilities for working with the local dataset cache.
This file is adapted from the AllenNLP library at https://github.com/allenai/allennlp
Copyright by the AllenNLP authors.
"""
from __future__ import (absolute_import, division, print_function, unicode_literals)
import sys
import json
import logging
import os
impor... | 11,692 | 34.978462 | 144 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_ctrl.py | # coding=utf-8
# Copyright 2018 Salesforce and 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 copy of the License at
#
# h... | 24,528 | 47.380671 | 151 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/__init__.py | __version__ = "2.1.1"
# Work around to update TensorFlow's absl.logging threshold which alters the
# default Python logging output behavior when present.
# see: https://github.com/abseil/abseil-py/issues/99
# and: https://github.com/tensorflow/tensorflow/issues/26691#issuecomment-500369493
try:
import absl.logging... | 10,661 | 58.898876 | 128 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_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... | 55,995 | 51.283847 | 193 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/convert_bert_original_tf_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 2,577 | 38.060606 | 101 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_distilbert.py | # coding=utf-8
# Copyright 2019-present, the HuggingFace Inc. team, The Google AI Language Team and Facebook, Inc.
#
# 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... | 37,652 | 48.674142 | 201 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/convert_bert_pytorch_checkpoint_to_original_tf.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 4,478 | 33.19084 | 115 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_transfo_xl.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 41,005 | 44.012075 | 157 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/convert_xlnet_original_tf_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 4,334 | 40.285714 | 126 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_xlnet.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 74,020 | 52.252518 | 169 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_xlm.py | # coding=utf-8
# Copyright 2019-present, Facebook, Inc and the HuggingFace Inc. team.
#
# 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
#
# Un... | 46,645 | 50.542541 | 163 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_tf_utils.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... | 26,511 | 51.812749 | 472 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_ctrl.py | # coding=utf-8
# Copyright 2018 Salesforce and 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 copy of the License at
#
# h... | 24,667 | 48.139442 | 146 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tokenization_transfo_xl.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 21,824 | 36.62931 | 133 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_transfo_xl_utilities.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University 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 Lice... | 13,568 | 39.747748 | 132 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/convert_pytorch_checkpoint_to_tf2.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# 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... | 15,133 | 61.02459 | 215 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/modeling_roberta.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... | 30,485 | 53.634409 | 151 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tokenization_utils.py | # coding=utf-8
# Copyright 2018 The Open AI Team Authors and The HuggingFace Inc. team.
#
# 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
#
# ... | 55,072 | 50.422035 | 372 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_transfo_xl_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 8,700 | 38.912844 | 94 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/tokenization_transfo_xl_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 2,975 | 35.292683 | 120 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_openai_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 8,855 | 39.81106 | 124 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_roberta_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 11,393 | 41.834586 | 143 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_common_test.py | # coding=utf-8
# Copyright 2019 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | 35,615 | 42.593635 | 137 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_auto_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 4,263 | 42.510204 | 122 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_bert_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 18,964 | 50.256757 | 235 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_encoder_decoder_test.py | # coding=utf-8
# Copyright 2018 The Hugging Face Inc. Team
#
# 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... | 1,960 | 35.314815 | 77 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/optimization_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 6,670 | 43.178808 | 143 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_xlnet_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 14,578 | 42.519403 | 131 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_distilbert_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 10,800 | 43.632231 | 152 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_tf_distilbert_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 9,856 | 43.201794 | 151 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_tf_transfo_xl_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 8,483 | 37.917431 | 104 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_tf_common_test.py | # coding=utf-8
# Copyright 2019 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | 21,957 | 44.556017 | 140 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_xlm_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 13,845 | 41.472393 | 171 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_gpt2_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# 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 ... | 10,296 | 40.353414 | 135 | py |
TURL-release_ongoing | TURL-release_ongoing/model/transformers/tests/modeling_ctrl_test.py | # coding=utf-8
# Copyright 2018 Salesforce and HuggingFace Inc. team.
# 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 a... | 8,667 | 39.12963 | 135 | py |
MatchFlow | MatchFlow-main/main.py | from __future__ import print_function, division
import sys
sys.path.append('core')
import argparse, configparser
import os
import cv2
import numpy as np
import matplotlib
matplotlib.use('Agg')
import torch
import torch.nn as nn
import torch.optim as optim
from network import RAFTGMA_QuadtreeFnet
import datasets
impo... | 9,264 | 33.962264 | 123 | py |
MatchFlow | MatchFlow-main/evaluate.py | import sys
sys.path.append('core')
from PIL import Image
import argparse
import os
import numpy as np
import torch
import imageio
import torchvision
from network import RAFTGMA, RAFTGMA_QuadtreeFnet
import torch.nn.functional as F
import datasets
from utils import flow_viz
from utils import frame_utils
from utils.util... | 9,628 | 38.302041 | 136 | py |
MatchFlow | MatchFlow-main/evaluate_tile.py | import sys
sys.path.append('core')
from PIL import Image
import os
import numpy as np
import torch
import torch.nn.functional as F
import datasets
from utils import flow_viz
from utils import frame_utils
import imageio
import math
def compute_grid_indices(image_shape, patch_size, min_overlap=20):
if min_overlap... | 6,838 | 37.638418 | 118 | py |
MatchFlow | MatchFlow-main/core/quadtree_attention.py | import sys
import torch
import torch.nn as nn
import torch.nn.functional as F
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
sys.path.append("./QuadTreeAttention")
from QuadtreeAttention.modules.quadtree_attention import QTAttA, QTAttB
class QuadtreeAttention(nn.Module):
def __init__(
... | 3,030 | 31.244681 | 93 | py |
MatchFlow | MatchFlow-main/core/corr.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import math
from utils.utils import bilinear_sampler, coords_grid
# from compute_sparse_correlation import compute_sparse_corr, compute_sparse_corr_torch, compute_sparse_corr_mink
try:
import alt_cuda_corr
except:
# alt_cuda_corr is not compile... | 3,533 | 32.657143 | 113 | py |
MatchFlow | MatchFlow-main/core/network.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from update import BasicUpdateBlock, GMAUpdateBlock
from extractor import BasicEncoder
from matching_encoder import MatchingModel
from corr import CorrBlock
from utils.utils import bilinear_sampler, coords_grid, upflow8, upflow2
from gma import Attenti... | 5,078 | 32.635762 | 118 | py |
MatchFlow | MatchFlow-main/core/update.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from gma import Aggregate
class FlowHead(nn.Module):
def __init__(self, input_dim=128, hidden_dim=256):
super(FlowHead, self).__init__()
self.conv1 = nn.Conv2d(input_dim, hidden_dim, 3, padding=1)
self.conv2 = nn.Conv2d(hid... | 5,066 | 35.192857 | 101 | py |
MatchFlow | MatchFlow-main/core/extractor.py | import torch
import torch.nn as nn
class ResidualBlock(nn.Module):
def __init__(self, in_planes, planes, norm_fn='group', stride=1):
super(ResidualBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, padding=1, stride=stride)
self.conv2 = nn.Conv2d(planes, plan... | 6,398 | 32.857143 | 97 | py |
MatchFlow | MatchFlow-main/core/datasets.py | # Data loading based on https://github.com/NVIDIA/flownet2-pytorch
import numpy as np
import torch
import torch.utils.data as data
import os
import random
from glob import glob
import os.path as osp
from utils import frame_utils
from utils.augmentor import FlowAugmentor, SparseFlowAugmentor
class FlowDataset(data.D... | 12,766 | 41.556667 | 117 | py |
MatchFlow | MatchFlow-main/core/common.py | def torch_init_model(model, total_dict, key, rank=0):
if key in total_dict:
state_dict = total_dict[key]
else:
state_dict = total_dict
missing_keys = []
unexpected_keys = []
error_msgs = []
# copy state_dict so _load_from_state_dict can modify it
metadata = getattr(state_dict... | 1,148 | 37.3 | 119 | py |
MatchFlow | MatchFlow-main/core/matching_encoder.py | import torch
import torch.nn as nn
from einops.einops import rearrange
from resnet_fpn import ResNetFPN_8_2
import math
import copy
from quadtree_attention import QuadtreeAttention
from common import torch_init_model
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
class DWConv(nn.Module):
def __... | 11,401 | 38.047945 | 130 | py |
MatchFlow | MatchFlow-main/core/gma.py | import torch
from torch import nn, einsum
from einops import rearrange
class RelPosEmb(nn.Module):
def __init__(
self,
max_pos_size,
dim_head
):
super().__init__()
self.rel_height = nn.Embedding(2 * max_pos_size - 1, dim_head)
self.rel_width = nn.Emb... | 3,428 | 26.653226 | 96 | py |
MatchFlow | MatchFlow-main/core/resnet_fpn.py | import torch.nn as nn
import torch
def conv1x1(in_planes, out_planes, stride=1):
"""1x1 convolution without padding"""
return nn.Conv2d(in_planes, out_planes, kernel_size=1, stride=stride, padding=0, bias=False)
def conv3x3(in_planes, out_planes, stride=1):
"""3x3 convolution with padding"""
return ... | 4,219 | 31.96875 | 102 | py |
MatchFlow | MatchFlow-main/core/utils/utils.py | import torch
import torch.nn.functional as F
import numpy as np
from scipy import interpolate
# from torch_scatter import scatter_softmax, scatter_add
class InputPadder:
""" Pads images such that dimensions are divisible by 32 """
def __init__(self, dims, mode='sintel'):
self.ht, self.wd = dims[-2:]
... | 7,470 | 32.204444 | 98 | py |
MatchFlow | MatchFlow-main/core/utils/augmentor.py | import numpy as np
import random
import math
from PIL import Image
import cv2
cv2.setNumThreads(0)
cv2.ocl.setUseOpenCL(False)
import torch
from torchvision.transforms import ColorJitter
import torch.nn.functional as F
class FlowAugmentor:
def __init__(self, crop_size, min_scale=-0.2, max_scale=0.5, do_flip=Tru... | 9,310 | 35.802372 | 97 | py |
MatchFlow | MatchFlow-main/QuadTreeAttention/setup.py | #!/usr/bin/env python
import os
from setuptools import setup, find_packages
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
this_file = os.path.dirname(__file__)
setup(
name="quadtree_attention_package",
ext_modules=[
CUDAExtension(
"score_computation_cuda",
... | 899 | 27.125 | 68 | py |
MatchFlow | MatchFlow-main/QuadTreeAttention/QuadtreeAttention/functions/quadtree_attention.py | import torch
from torch.autograd import Function
import score_computation_cuda
import value_aggregation_cuda
from einops.einops import rearrange
class ScoreComputation(Function):
@staticmethod
def forward(ctx, query, key, index):
x = score_computation_cuda.score_forward(query, key, index)
ctx.... | 2,123 | 35 | 115 | py |
MatchFlow | MatchFlow-main/QuadTreeAttention/QuadtreeAttention/modules/quadtree_attention.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from functools import partial
from timm.models.layers import DropPath, to_2tuple, trunc_normal_
from timm.models.registry import register_model
from timm.models.vision_transformer import _cfg
import math
from ..functions.quadtree_attention import score... | 11,733 | 41.669091 | 120 | py |
dl-4-tsc | dl-4-tsc-master/classifiers/fcn.py | # FCN model
# when tuning start with learning rate->mini_batch_size ->
# momentum-> #hidden_units -> # learning_rate_decay -> #layers
import tensorflow.keras as keras
import tensorflow as tf
import numpy as np
import time
from utils.utils import save_logs
from utils.utils import calculate_metrics
class Classifier_... | 3,295 | 32.292929 | 89 | py |
dl-4-tsc | dl-4-tsc-master/classifiers/inception.py | import tensorflow.keras as keras
import tensorflow as tf
import numpy as np
import time
from utils.utils import save_logs
from utils.utils import calculate_metrics
from utils.utils import save_test_duration
class Classifier_INCEPTION:
def __init__(self, output_directory, input_shape, nb_classes, verbose=False, ... | 6,076 | 37.462025 | 120 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.