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 |
|---|---|---|---|---|---|---|
OFA | OFA-main/fairseq/fairseq/tasks/language_modeling.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
from dataclasses import dataclass, field
from typing import Optional
import numpy as np
import torch
from fairseq im... | 13,864 | 35.486842 | 97 | py |
OFA | OFA-main/fairseq/fairseq/tasks/translation.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass, field
import itertools
import json
import logging
import os
from typing import Optional
from argparse impor... | 17,883 | 35.202429 | 108 | py |
OFA | OFA-main/fairseq/fairseq/tasks/multilingual_masked_lm.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import numpy as np
import torch
from fairseq import utils
from fairseq.data import (
ConcatDataset,
Dictiona... | 12,146 | 34.831858 | 87 | py |
OFA | OFA-main/fairseq/fairseq/tasks/online_backtranslation.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import contextlib
import json
import logging
import math
import os
from argparse import Namespace
from collections import OrderedDict, default... | 28,578 | 40.843338 | 118 | py |
OFA | OFA-main/fairseq/fairseq/tasks/multilingual_translation.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import contextlib
import logging
import os
from collections import OrderedDict
from argparse import ArgumentError
import torch
from fairseq i... | 18,125 | 38.149028 | 118 | py |
OFA | OFA-main/fairseq/fairseq/tasks/translation_lev.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from dataclasses import dataclass, field
import torch
from fairseq import utils
from fairseq.data import LanguagePairDataset
from fairseq.data... | 7,419 | 37.645833 | 103 | py |
OFA | OFA-main/fairseq/fairseq/tasks/fairseq_task.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import warnings
from argparse import Namespace
from typing import Any, Callable, Dict, List
import torch
from fairse... | 25,451 | 37.044843 | 110 | py |
OFA | OFA-main/fairseq/fairseq/tasks/audio_finetuning.py | # Copyright (c) 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the LICENSE file in
# the root directory of this source tree. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
import logging
import os
import to... | 13,599 | 38.193084 | 95 | py |
OFA | OFA-main/fairseq/fairseq/tasks/translation_multi_simple_epoch.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import datetime
import logging
import time
import torch
from fairseq.data import (
FairseqDataset,
LanguagePairDataset,
ListDatas... | 17,275 | 39.083527 | 113 | py |
OFA | OFA-main/fairseq/docs/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# fairseq documentation build configuration file, created by
# sphinx-quickstart on Fri Aug 17 21:45:30 2018.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# au... | 4,270 | 30.637037 | 80 | py |
OFA | OFA-main/fairseq/fairseq_cli/generate.py | #!/usr/bin/env python3 -u
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Translate pre-processed data with a trained model.
"""
import ast
import logging
import math
import os
import sy... | 15,831 | 37.149398 | 180 | py |
OFA | OFA-main/fairseq/fairseq_cli/validate.py | #!/usr/bin/env python3 -u
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
import sys
from argparse import Namespace
from itertools import chain
import torch
from fa... | 5,242 | 32.608974 | 88 | py |
OFA | OFA-main/fairseq/fairseq_cli/hydra_train.py | #!/usr/bin/env python3 -u
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import logging
import os
from fairseq.dataclass.initialize import add_defaults, hydra_init
from fairseq_cli.train i... | 2,655 | 28.842697 | 116 | py |
OFA | OFA-main/fairseq/fairseq_cli/eval_lm.py | #!/usr/bin/env python3 -u
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Evaluate the perplexity of a trained language model.
"""
import logging
import math
import os
import sys
from a... | 11,961 | 33.373563 | 108 | py |
OFA | OFA-main/fairseq/fairseq_cli/interactive.py | #!/usr/bin/env python3 -u
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Translate raw text with a trained model. Batches data on-the-fly.
"""
import ast
import fileinput
import logging... | 11,436 | 35.078864 | 90 | py |
OFA | OFA-main/fairseq/fairseq_cli/train.py | #!/usr/bin/env python3 -u
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Train a new model on one or across multiple GPUs.
"""
import argparse
import logging
import math
import os
impor... | 18,443 | 34.813592 | 109 | py |
OFA | OFA-main/utils/checkpoint_utils.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import ast
import collections
import contextlib
import logging
import numpy as np
import os
import re
import time
import traceback
import math... | 34,100 | 37.928082 | 114 | py |
OFA | OFA-main/utils/zero_shot_utils.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import string
import math
import torch
from data import data_utils
def get_symbols_to_strip_from_output(generator):
if hasattr(generator, "s... | 6,421 | 43.597222 | 116 | py |
OFA | OFA-main/utils/eval_utils.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import string
import math
import json
from itertools import chain
import os
import torch
import torch.distributed as dist
from fairseq import utils... | 20,299 | 46.209302 | 122 | py |
OFA | OFA-main/utils/transforms.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import random
import torch
import torchvision.transforms as T
import torchvision.transforms.functional as F
import numpy as np
from PIL import Imag... | 18,520 | 35.033074 | 109 | py |
OFA | OFA-main/data/data_utils.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
import contextlib
import itertools
import log... | 22,740 | 34.532813 | 120 | py |
OFA | OFA-main/data/ofa_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import logging
import re
import torch.utils.data
from fairseq.data import FairseqDataset
import string
CHINESE_PUNCTUATION = '"#$%&'()*+,-/:... | 3,017 | 30.4375 | 119 | py |
OFA | OFA-main/data/file_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import os
import torch
import pickle
class FileDataset:
def __init__(self, file_path, selected_col_ids=None, dtypes=None, separator="\t", cach... | 4,580 | 41.416667 | 120 | py |
OFA | OFA-main/data/pretrain_data/unify_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from io import BytesIO
import math
import logging
import random
import warnings
import numpy as np
import torch
import base64
from torchvision impor... | 27,349 | 41.935636 | 125 | py |
OFA | OFA-main/data/nlg_data/summary_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import logging
import warnings
import torch
import numpy as np
from data import data_utils
from data.ofa_dataset import OFADataset
logger = logging.... | 4,104 | 30.335878 | 100 | py |
OFA | OFA-main/data/s2t_data/unify_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from io import BytesIO
import math
import logging
import random
import warnings
import numpy as np
import torch
import base64
from torchvision impor... | 21,288 | 36.283713 | 114 | py |
OFA | OFA-main/data/nlu_data/qnli_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import logging
import warnings
import torch
import numpy as np
from data import data_utils
from data.ofa_dataset import OFADataset
logger = loggin... | 4,674 | 31.922535 | 93 | py |
OFA | OFA-main/data/nlu_data/cola_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import logging
import warnings
import torch
import numpy as np
from data import data_utils
from data.ofa_dataset import OFADataset
logger = loggin... | 4,485 | 31.273381 | 98 | py |
OFA | OFA-main/data/nlu_data/qqp_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import logging
import warnings
import torch
import numpy as np
from data import data_utils
from data.ofa_dataset import OFADataset
logger = loggin... | 4,627 | 31.591549 | 94 | py |
OFA | OFA-main/data/nlu_data/mrpc_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import logging
import warnings
import torch
import numpy as np
from data import data_utils
from data.ofa_dataset import OFADataset
logger = loggin... | 4,638 | 31.669014 | 104 | py |
OFA | OFA-main/data/nlu_data/sst2_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import logging
import warnings
import torch
import numpy as np
from data import data_utils
from data.ofa_dataset import OFADataset
logger = loggin... | 4,508 | 31.438849 | 110 | py |
OFA | OFA-main/data/nlu_data/mnli_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import logging
import warnings
import torch
import numpy as np
from data import data_utils
from data.ofa_dataset import OFADataset
logger = loggin... | 4,669 | 31.430556 | 93 | py |
OFA | OFA-main/data/nlu_data/rte_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import logging
import warnings
import torch
import numpy as np
from data import data_utils
from data.ofa_dataset import OFADataset
logger = loggin... | 4,636 | 31.65493 | 93 | py |
OFA | OFA-main/data/mm_data/vqa_gen_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from io import BytesIO
import logging
import warnings
import numpy as np
import torch
import base64
from torchvision import transforms
from PIL i... | 7,783 | 34.543379 | 103 | py |
OFA | OFA-main/data/mm_data/refcoco_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from io import BytesIO
import logging
import warnings
import numpy as np
import torch
import base64
import utils.transforms as T
from PIL import ... | 6,286 | 34.925714 | 101 | py |
OFA | OFA-main/data/mm_data/ocr_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from io import BytesIO
import logging
import warnings
import random
import functools
import numpy as np
import torch
import base64
from torchvision i... | 6,609 | 31.243902 | 95 | py |
OFA | OFA-main/data/mm_data/snli_ve_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from io import BytesIO
import logging
import warnings
import numpy as np
import torch
import base64
from torchvision import transforms
from PIL i... | 7,087 | 33.745098 | 118 | py |
OFA | OFA-main/data/mm_data/image_gen_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from io import BytesIO
import logging
import warnings
import base64
import random
import numpy as np
import torch
from PIL import Image, ImageFil... | 5,240 | 29.47093 | 91 | py |
OFA | OFA-main/data/mm_data/caption_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from io import BytesIO
import logging
import warnings
import string
import numpy as np
import torch
import base64
from torchvision import transfor... | 5,146 | 30.968944 | 104 | py |
OFA | OFA-main/data/cv_data/image_classify_dataset.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from io import BytesIO
import logging
import warnings
import functools
import numpy as np
import torch
import base64
from torchvision import trans... | 6,780 | 33.42132 | 184 | py |
OFA | OFA-main/tasks/ofa_task.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from dataclasses import dataclass, field
import logging
import os
import math
import torch
from typing import Dict, Optional
from fairseq import se... | 13,455 | 37.011299 | 103 | py |
OFA | OFA-main/tasks/nlg_tasks/gigaword.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from dataclasses import dataclass, field
import json
import logging
import string
from typing import Optional
from argparse import Namespace
from fair... | 10,653 | 40.455253 | 244 | py |
OFA | OFA-main/tasks/cv_tasks/image_classify.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from dataclasses import dataclass, field
import json
import logging
import os
import math
import pickle
from typing import Optional
from data.file_d... | 9,135 | 41.296296 | 122 | py |
OFA | OFA-main/tasks/mm_tasks/caption.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from dataclasses import dataclass, field
import json
import logging
from typing import Optional
from argparse import Namespace
from itertools import... | 9,741 | 37.968 | 117 | py |
OFA | OFA-main/tasks/mm_tasks/refcoco.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from dataclasses import dataclass, field
import json
import logging
from typing import Optional
from argparse import Namespace
import torch
from fa... | 6,125 | 37.049689 | 94 | py |
OFA | OFA-main/tasks/mm_tasks/image_gen.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from dataclasses import dataclass, field
import json
import logging
import os
import math
import base64
from typing import Optional
from argparse im... | 13,169 | 38.909091 | 180 | py |
OFA | OFA-main/tasks/mm_tasks/vqa_gen.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from dataclasses import dataclass, field
import json
import logging
import os
import math
import pickle
from typing import Optional
from argparse im... | 13,237 | 43.874576 | 139 | py |
OFA | OFA-main/tasks/mm_tasks/ocr.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import torch
from dataclasses import dataclass, field
import json
import logging
from typing import Optional
from argparse import Namespace
import Lev... | 5,097 | 33.917808 | 91 | py |
OFA | OFA-main/tasks/mm_tasks/snli_ve.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import json
import logging
import math
from dataclasses import dataclass, field
from typing import Optional
import torch
from fairseq import metric... | 8,650 | 42.691919 | 135 | py |
OFA | OFA-main/tasks/nlu_tasks/rte.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import json
import logging
import math
from dataclasses import dataclass, field
from typing import Optional
import torch
from fairseq import metric... | 4,541 | 36.229508 | 122 | py |
OFA | OFA-main/tasks/nlu_tasks/sst2.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import json
import logging
import math
from dataclasses import dataclass, field
from typing import Optional
import torch
from fairseq import metric... | 4,559 | 36.377049 | 122 | py |
OFA | OFA-main/tasks/nlu_tasks/mrpc.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import json
import logging
import math
from dataclasses import dataclass, field
from typing import Optional
import torch
from fairseq import metric... | 5,477 | 38.985401 | 122 | py |
OFA | OFA-main/tasks/nlu_tasks/qnli.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import json
import logging
import math
from dataclasses import dataclass, field
from typing import Optional
import torch
from fairseq import metric... | 4,549 | 36.295082 | 122 | py |
OFA | OFA-main/tasks/nlu_tasks/cola.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import json
import logging
import math
from dataclasses import dataclass, field
from typing import Optional
import torch
from fairseq import metrics... | 5,819 | 39.137931 | 122 | py |
OFA | OFA-main/tasks/nlu_tasks/mnli.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import json
import logging
import math
from dataclasses import dataclass, field
from typing import Optional
import torch
from fairseq import metric... | 4,561 | 36.393443 | 122 | py |
OFA | OFA-main/tasks/nlu_tasks/qqp.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
import json
import logging
import math
from dataclasses import dataclass, field
from typing import Optional
import torch
from fairseq import metric... | 5,458 | 38.557971 | 122 | py |
OFA | OFA-main/tasks/speech_tasks/unify_task.py | # Copyright 2022 The OFA-Sys Team.
# All rights reserved.
# This source code is licensed under the Apache 2.0 license
# found in the LICENSE file in the root directory.
from dataclasses import dataclass, field
import json
import logging
import os
import math
from typing import Optional
from fairseq.tasks import regist... | 13,149 | 34.831063 | 117 | py |
SB_loss_PA | SB_loss_PA-main/src/traintest_SB_pred.py | # -*- coding: utf-8 -*-
# @Time : Jan/24/2023
# @Author : Heejin Do
# @File : traintest_SB_loss.py
# This code is based on the open source project GOPT by Yuan Gong
# Original repository: https://github.com/YuanGongND/gopt
# train and test the models
import sys
import os
import time
from torch.utils.data import... | 20,027 | 46.799523 | 182 | py |
SB_loss_PA | SB_loss_PA-main/src/traintest_gopt.py | # -*- coding: utf-8 -*-
# @Time : 9/20/21 12:02 PM
# @Author : Yuan Gong
# @Affiliation : Massachusetts Institute of Technology
# @Email : yuangong@mit.edu
# @File : traintest.py
# train and test the models
import sys
import os
import time
from torch.utils.data import Dataset, DataLoader
sys.path.append(os.... | 17,789 | 44.382653 | 182 | py |
SB_loss_PA | SB_loss_PA-main/src/models/gopt.py | # -*- coding: utf-8 -*-
# @Time : 10/22/21 1:23 PM
# @Author : Yuan Gong
# @Affiliation : Massachusetts Institute of Technology
# @Email : yuangong@mit.edu
# @File : gopt.py
# attention part is borrowed from the timm package.
import math
import warnings
import torch
import torch.nn as nn
import numpy as np
... | 13,247 | 41.461538 | 122 | py |
trojan-malware-in-bio-cyber-attacks | trojan-malware-in-bio-cyber-attacks-main/trojan_attack/trojan_cnn.py | # import section
from os import walk
import numpy as np
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
from tensorflow.keras.optimizers import SGD, Adam, Adadelta
from tensorflow.keras.layers import Conv1D, Dense, MaxPooling1D, Flatten, Dropout
from tensorflow.keras.models import Sequential
from tensor... | 7,793 | 42.541899 | 121 | py |
DoXpy | DoXpy-master/doxpy/doxpy/models/model_manager.py | import os
import random
import re
# os.environ["CUDA_VISIBLE_DEVICES"]="-1"
import multiprocessing
import types
import spacy # for natural language processing
# import neuralcoref # for Coreference Resolution
# python3 -m spacy download en_core_web_md
from sklearn.preprocessing import normalize
from sklearn.metrics.pai... | 27,641 | 40.318386 | 320 | py |
DenseNet-Keras | DenseNet-Keras-master/densenet121.py | from keras.models import Model
from keras.layers import Input, merge, ZeroPadding2D
from keras.layers.core import Dense, Dropout, Activation
from keras.layers.convolutional import Convolution2D
from keras.layers.pooling import AveragePooling2D, GlobalAveragePooling2D, MaxPooling2D
from keras.layers.normalization import... | 6,939 | 39.348837 | 146 | py |
DenseNet-Keras | DenseNet-Keras-master/densenet161.py | from keras.models import Model
from keras.layers import Input, merge, ZeroPadding2D
from keras.layers.core import Dense, Dropout, Activation
from keras.layers.convolutional import Convolution2D
from keras.layers.pooling import AveragePooling2D, GlobalAveragePooling2D, MaxPooling2D
from keras.layers.normalization import... | 6,939 | 39.348837 | 146 | py |
DenseNet-Keras | DenseNet-Keras-master/test_inference.py | """Test ImageNet pretrained DenseNet"""
import cv2
import numpy as np
from keras.optimizers import SGD
import keras.backend as K
# We only test DenseNet-121 in this script for demo purpose
from densenet121 import DenseNet
im = cv2.resize(cv2.imread('resources/cat.jpg'), (224, 224)).astype(np.float32)
#im = cv2.resi... | 1,538 | 31.0625 | 83 | py |
DenseNet-Keras | DenseNet-Keras-master/custom_layers.py | from keras.engine import Layer, InputSpec
try:
from keras import initializations
except ImportError:
from keras import initializers as initializations
import keras.backend as K
class Scale(Layer):
'''Custom Layer for DenseNet used for BatchNormalization.
Learns a set of weights and biases used for... | 3,340 | 44.148649 | 108 | py |
DenseNet-Keras | DenseNet-Keras-master/densenet169.py | from keras.models import Model
from keras.layers import Input, merge, ZeroPadding2D
from keras.layers.core import Dense, Dropout, Activation
from keras.layers.convolutional import Convolution2D
from keras.layers.pooling import AveragePooling2D, GlobalAveragePooling2D, MaxPooling2D
from keras.layers.normalization import... | 6,935 | 39.325581 | 146 | py |
CanonicalVoting | CanonicalVoting-main/eval_separate.py | import numpy as np
from tqdm import tqdm
import torch
from utils.dataloader import ScanNetXYZProbMultiDataset, SceneNNDataset
from utils.minkunet import MinkUNet34C
from time import time
import hv_cuda
import logging
import os
logger = logging.getLogger(__name__)
import MinkowskiEngine as ME
from train_joint import col... | 13,134 | 42.783333 | 254 | py |
CanonicalVoting | CanonicalVoting-main/train_joint.py | from utils.calc_map import eval_det_multiprocessing, get_iou_obb
from utils.dataloader import ScanNetXYZProbMultiDataset
import torch
import hydra
from utils.minkunet import MinkUNet34C
import logging
import numpy as np
from tqdm import tqdm
import MinkowskiEngine as ME
import hv_cuda
import torch.nn as nn
import os
l... | 21,520 | 44.212185 | 261 | py |
CanonicalVoting | CanonicalVoting-main/eval_joint.py | from utils.calc_map import eval_det_multiprocessing, get_iou_obb
from utils.dataloader import ScanNetXYZProbMultiDataset, SceneNNDataset
import torch
import hydra
from utils.minkunet import MinkUNet34C
import logging
import numpy as np
from tqdm import tqdm
import MinkowskiEngine as ME
import hv_cuda
import torch.nn as... | 13,291 | 41.196825 | 253 | py |
CanonicalVoting | CanonicalVoting-main/train_separate.py | import torch
import hydra
from utils.dataloader import ScanNetXYZProbSymDataset
from utils.minkunet import MinkUNet34C
import logging
import numpy as np
from tqdm import tqdm
import MinkowskiEngine as ME
import hv_cuda
import hydra.utils as utils
import torch.nn as nn
from utils.calc_map import eval_det_multiprocessing... | 19,819 | 41.900433 | 261 | py |
CanonicalVoting | CanonicalVoting-main/houghvoting/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='houghvoting',
ext_modules=[
CUDAExtension('hv_cuda', [
'src/hv_cuda.cpp',
'src/hv_cuda_kernel.cu',
])
],
zipsafe=False,
cmdclass={
'build_ext... | 344 | 22 | 67 | py |
CanonicalVoting | CanonicalVoting-main/sunrgbd/brnetcanon.py | import os
import pdb
import pickle
import torch
from mmdet.models import DETECTORS
from .two_stage import TwoStage3DDetector
import torch.nn as nn
from model_utils.minkunet import MinkUNet34C
import MinkowskiEngine as ME
from visdom import Visdom
import cv2
import numpy as np
import hv_cuda
def farthest_point_sample(... | 13,923 | 38.444759 | 165 | py |
CanonicalVoting | CanonicalVoting-main/utils/resnet.py | # Copyright (c) Chris Choy (chrischoy@ai.stanford.edu).
#
# 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, ... | 7,152 | 29.699571 | 87 | py |
CanonicalVoting | CanonicalVoting-main/utils/dataloader.py | import torch.utils.data as torchdata
import numpy as np
import os
import json
from plyfile import PlyData
import quaternion
import MinkowskiEngine as ME
import pickle
import collections
import h5py
def get_top8_classes_mapping(): ... | 22,775 | 45.292683 | 409 | py |
CanonicalVoting | CanonicalVoting-main/utils/minkunet.py | # Copyright (c) Chris Choy (chrischoy@ai.stanford.edu).
#
# 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, ... | 11,302 | 30.48468 | 113 | py |
glm_saga | glm_saga-main/tests.py | from glm_saga.elasticnet import *
from sklearn.linear_model import LogisticRegression, ElasticNet
from sklearn.datasets import make_classification, make_regression
from sklearn.metrics import r2_score
def toy_example(verbose=False, tol=1e-5):
NITERS = 2000
NUM_CLASSES=3
ALPHA = 0.5
STEP_SIZE = 1
... | 15,485 | 34.6 | 186 | py |
glm_saga | glm_saga-main/setup.py | from setuptools import find_packages, setup
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setup(
name='glm_saga',
version='0.1.2',
description="A PyTorch solver for elastic net",
long_description=long_description,
long_description_content_type="text/markdown... | 553 | 24.181818 | 52 | py |
glm_saga | glm_saga-main/resnet18_example.py | import torch as ch
import torch.nn as nn
from torch.utils.data import DataLoader, TensorDataset
import torchvision.models as models
from glm_saga.elasticnet import IndexedTensorDataset, glm_saga
# Setup a typical dummy problem, and remove the last fully
# connected layer of the model to return the representation
N_EX... | 1,445 | 29.765957 | 80 | py |
glm_saga | glm_saga-main/glm_saga/elasticnet.py | # import waitGPU
# waitGPU.wait(nproc=0, ngpu=2)
# debugging
# import os
# os.environ['CUDA_LAUNCH_BLOCKING'] = "1"
import torch as ch
import torch.nn as nn
import torch.nn.functional as F
from torch.optim import Adam, SGD
from torch.optim.lr_scheduler import StepLR
from torch.autograd import grad
from torch.utils.da... | 28,348 | 36.057516 | 213 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/setup.py | """
Simple check list from AllenNLP repo: https://github.com/allenai/allennlp/blob/master/setup.py
To create the package for pypi.
1. Change the version in __init__.py and setup.py.
2. Commit these changes with the message: "Release: VERSION"
3. Add a tag in git to mark the release: "git tag VERSION -m'Adds tag VER... | 2,722 | 37.9 | 104 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/examples/run_lm_finetuning.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace 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... | 27,989 | 42.194444 | 139 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/examples/run_squad.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace 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... | 48,913 | 44.928638 | 141 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/examples/run_classifier.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace 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... | 29,129 | 41.964602 | 139 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/examples/run_swag.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace 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... | 23,213 | 42.553471 | 139 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/examples/extract_features.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace 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/LICENS... | 12,196 | 39.92953 | 120 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/tests/modeling_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,083 | 43.352542 | 137 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/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 ... | 1,821 | 34.72549 | 93 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/tests/tokenization_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,963 | 35.233577 | 100 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/pytorch_pretrained_bert/optimization.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace 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/LICENS... | 6,803 | 40.742331 | 116 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/pytorch_pretrained_bert/__main__.py | # coding: utf8
def main():
import sys
try:
from .convert_tf_checkpoint_to_pytorch import convert_tf_checkpoint_to_pytorch
except ModuleNotFoundError:
print("pytorch_pretrained_bert can only be used from the commandline to convert TensorFlow models in PyTorch, "
"In that case, i... | 932 | 39.565217 | 137 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/pytorch_pretrained_bert/modeling.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HugginFace 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... | 55,267 | 48.302409 | 139 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/pytorch_pretrained_bert/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.
"""
import os
import logging
import shutil
import tempfile
import json
from urllib.parse import urlparse
from pathlib import Path
from typing ... | 8,021 | 32.425 | 98 | py |
AMPERSAND-EMNLP2019 | AMPERSAND-EMNLP2019-master/argmining/pytorch_pretrained_bert/convert_tf_checkpoint_to_pytorch.py | # coding=utf-8
# Copyright 2018 The HugginFace 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 | 38.637168 | 101 | py |
trVAE_reproducibility | trVAE_reproducibility-master/reptrvae/data_loader.py | import os
import tarfile
import zipfile
import anndata
import cv2
import keras
import numpy as np
import pandas as pd
import scanpy as sc
from PIL import Image
def prepare_and_load_celeba(file_path, attr_path, landmark_path,
gender='Male', attribute='Smiling',
... | 8,139 | 36.685185 | 118 | py |
trVAE_reproducibility | trVAE_reproducibility-master/reptrvae/models/_activations.py | import tensorflow as tf
from keras import backend as K
from keras.layers import Activation, Lambda
from keras.layers.advanced_activations import LeakyReLU
def mean_activation(x):
return tf.clip_by_value(K.exp(x), 1e-5, 1e6)
def disp_activation(x):
return tf.clip_by_value(tf.nn.softplus(x), 1e-4, 1e4)
ACTI... | 724 | 30.521739 | 72 | py |
trVAE_reproducibility | trVAE_reproducibility-master/reptrvae/models/_layers.py | from keras import backend as K
from keras.engine.topology import Layer
class SliceLayer(Layer):
def __init__(self, index=0, **kwargs):
self.index = index
super().__init__(**kwargs)
def build(self, input_shape):
if not isinstance(input_shape, list):
raise ValueError('Input ... | 1,100 | 26.525 | 68 | py |
trVAE_reproducibility | trVAE_reproducibility-master/reptrvae/models/_scgen.py | import logging
import os
import anndata
import keras
import numpy
from keras import backend as K, Model
from keras.callbacks import CSVLogger, EarlyStopping
from keras.layers import Input, Dense, BatchNormalization, LeakyReLU, Dropout, Lambda
from keras.models import load_model
from scipy import sparse
from reptrvae.... | 14,523 | 39.232687 | 122 | py |
trVAE_reproducibility | trVAE_reproducibility-master/reptrvae/models/_trvae.py | import os
import anndata
import keras
import numpy as np
from keras.callbacks import CSVLogger, History, EarlyStopping, ReduceLROnPlateau, LambdaCallback
from keras.layers import Dense, BatchNormalization, Dropout, Input, concatenate, Lambda
from keras.layers.advanced_activations import LeakyReLU
from keras.models imp... | 20,554 | 47.025701 | 193 | py |
trVAE_reproducibility | trVAE_reproducibility-master/reptrvae/models/_utils.py | import numpy as np
import tensorflow as tf
from keras import backend as K
def compute_kernel(x, y, kernel='rbf', **kwargs):
"""
Computes RBF kernel between x and y.
# Parameters
x: Tensor
Tensor with shape [batch_size, z_dim]
y: Tensor
Tensor... | 3,962 | 36.037383 | 110 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.