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
robust-transformers
robust-transformers-main/tests/pipelines/test_pipelines_text_generation.py
# Copyright 2020 The HuggingFace 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 required by applicabl...
7,361
42.56213
172
py
robust-transformers
robust-transformers-main/tests/pipelines/test_pipelines_table_question_answering.py
# Copyright 2020 The HuggingFace 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 required by applicabl...
29,310
45.159055
121
py
robust-transformers
robust-transformers-main/tests/pipelines/test_pipelines_fill_mask.py
# Copyright 2020 The HuggingFace 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 required by applicabl...
17,646
44.132992
119
py
robust-transformers
robust-transformers-main/tests/pipelines/test_pipelines_question_answering.py
# Copyright 2020 The HuggingFace 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 required by applicabl...
18,250
49.980447
3,155
py
robust-transformers
robust-transformers-main/tests/pipelines/test_pipelines_common.py
# Copyright 2020 The HuggingFace 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 required by applicabl...
23,340
37.326765
153
py
robust-transformers
robust-transformers-main/tests/pipelines/test_pipelines_audio_classification.py
# Copyright 2021 The HuggingFace 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 required by applicabl...
4,140
31.606299
113
py
robust-transformers
robust-transformers-main/tests/byt5/test_tokenization_byt5.py
# coding=utf-8 # Copyright 2020 Google T5 Authors 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 requ...
14,880
44.929012
206
py
robust-transformers
robust-transformers-main/tests/vit/test_modeling_flax_vit.py
# Copyright 2021 The HuggingFace 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 required by applicabl...
9,884
40.016598
117
py
robust-transformers
robust-transformers-main/tests/vit/test_modeling_vit.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...
14,533
38.928571
118
py
robust-transformers
robust-transformers-main/tests/vit/test_feature_extraction_vit.py
# coding=utf-8 # Copyright 2021 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...
6,658
33.682292
111
py
robust-transformers
robust-transformers-main/tests/vit/test_modeling_tf_vit.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...
16,592
41.43734
121
py
robust-transformers
robust-transformers-main/tests/generation/test_generation_flax_logits_process.py
# coding=utf-8 # Copyright 2021 The HuggingFace Team 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 clone of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
12,690
41.023179
122
py
robust-transformers
robust-transformers-main/tests/generation/test_generation_stopping_criteria.py
# coding=utf-8 # Copyright 2020 The HuggingFace Team 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 clone of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
3,613
31.854545
98
py
robust-transformers
robust-transformers-main/tests/generation/test_generation_utils.py
# coding=utf-8 # Copyright 2020 The HuggingFace Team 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 clone of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
111,079
42.087665
293
py
robust-transformers
robust-transformers-main/tests/generation/test_generation_flax_utils.py
# Copyright 2021 The HuggingFace 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 required by applicabl...
10,710
37.66787
106
py
robust-transformers
robust-transformers-main/tests/generation/test_generation_logits_process.py
# coding=utf-8 # Copyright 2020 The HuggingFace Team 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 clone of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
21,525
41.457594
122
py
robust-transformers
robust-transformers-main/tests/generation/test_generation_beam_search.py
# coding=utf-8 # Copyright 2020 The HuggingFace Team 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 clone of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
24,325
42.439286
119
py
robust-transformers
robust-transformers-main/tests/generation/test_generation_beam_constraints.py
# coding=utf-8 # Copyright 2020 The HuggingFace Team 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 clone of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
4,445
37.327586
118
py
robust-transformers
robust-transformers-main/tests/vilt/test_feature_extraction_vilt.py
# coding=utf-8 # Copyright 2021 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...
9,796
37.876984
119
py
robust-transformers
robust-transformers-main/tests/vilt/test_modeling_vilt.py
# coding=utf-8 # Copyright 2022 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...
24,361
39.069079
211
py
robust-transformers
robust-transformers-main/tests/xlm_roberta_xl/test_modeling_xlm_roberta_xl.py
# coding=utf-8 # Copyright 2022 The HuggingFace 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 requir...
20,809
39.803922
117
py
robust-transformers
robust-transformers-main/tests/luke/test_modeling_luke.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...
26,798
38.179825
199
py
robust-transformers
robust-transformers-main/tests/luke/test_tokenization_luke.py
# coding=utf-8 # Copyright 2021 The HuggingFace 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 requir...
30,244
44.549699
213
py
robust-transformers
robust-transformers-main/tests/vit_mae/test_modeling_vit_mae.py
# coding=utf-8 # Copyright 2022 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...
17,639
39.645161
121
py
robust-transformers
robust-transformers-main/tests/bort/test_modeling_bort.py
# coding=utf-8 # Copyright 2020 The HuggingFace 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 requir...
1,893
35.423077
115
py
robust-transformers
robust-transformers-main/tests/convnext/test_modeling_convnext.py
# coding=utf-8 # Copyright 2022 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...
13,511
38.741176
315
py
robust-transformers
robust-transformers-main/tests/convnext/test_feature_extraction_convnext.py
# coding=utf-8 # Copyright 2022s 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 a...
6,844
33.923469
111
py
robust-transformers
robust-transformers-main/tests/layoutlmv2/test_feature_extraction_layoutlmv2.py
# coding=utf-8 # Copyright 2021 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...
12,929
57.243243
3,793
py
robust-transformers
robust-transformers-main/tests/layoutlmv2/test_processor_layoutlmv2.py
# Copyright 2021 The HuggingFace 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 required by applicabl...
22,549
51.44186
1,451
py
robust-transformers
robust-transformers-main/tests/layoutlmv2/test_modeling_layoutlmv2.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...
22,608
41.259813
917
py
robust-transformers
robust-transformers-main/tests/layoutlmv2/test_tokenization_layoutlmv2.py
# coding=utf-8 # Copyright 2021 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...
126,856
51.312165
1,398
py
robust-transformers
robust-transformers-main/tests/layoutlm/test_modeling_layoutlm.py
# coding=utf-8 # Copyright 2018 The Microsoft Research Asia LayoutLM Team Authors, The Hugging Face 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/license...
14,920
43.014749
937
py
robust-transformers
robust-transformers-main/tests/deberta_v2/test_modeling_deberta_v2.py
# coding=utf-8 # Copyright 2018 Microsoft 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 # # Unless ...
11,432
39.257042
119
py
robust-transformers
robust-transformers-main/tests/wavlm/test_modeling_wavlm.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...
23,759
39.477002
116
py
robust-transformers
robust-transformers-main/tests/marian/test_modeling_marian.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 ...
29,030
36.604922
123
py
robust-transformers
robust-transformers-main/tests/marian/test_modeling_flax_marian.py
# Copyright 2021 The HuggingFace 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 required by applicabl...
18,340
36.430612
118
py
robust-transformers
robust-transformers-main/tests/marian/test_tokenization_marian.py
# coding=utf-8 # Copyright 2020 Huggingface # # 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 agreed ...
7,926
56.861314
2,878
py
robust-transformers
robust-transformers-main/tests/marian/test_modeling_tf_marian.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...
17,741
39.506849
117
py
robust-transformers
robust-transformers-main/tests/flaubert/test_modeling_flaubert.py
# coding=utf-8 # Copyright 2020 The HuggingFace 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 requir...
16,077
34.888393
117
py
robust-transformers
robust-transformers-main/tests/mbart/test_modeling_flax_mbart.py
# Copyright 2021 The HuggingFace 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 required by applicabl...
18,947
39.748387
118
py
robust-transformers
robust-transformers-main/tests/mbart/test_tokenization_mbart.py
# Copyright 2020 The HuggingFace 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 required by applicabl...
13,969
41.852761
300
py
robust-transformers
robust-transformers-main/tests/mbart/test_modeling_tf_mbart.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...
14,316
40.378613
112
py
robust-transformers
robust-transformers-main/tests/mbart/test_modeling_mbart.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 ...
26,441
39.18541
298
py
robust-transformers
robust-transformers-main/tests/bigbird_pegasus/test_modeling_bigbird_pegasus.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...
109,884
141.153946
43,043
py
robust-transformers
robust-transformers-main/utils/tests_fetcher.py
# coding=utf-8 # Copyright 2021 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...
22,177
40.68797
117
py
robust-transformers
robust-transformers-main/utils/check_copies.py
# coding=utf-8 # Copyright 2020 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...
17,421
39.800937
163
py
robust-transformers
robust-transformers-main/utils/check_inits.py
# coding=utf-8 # Copyright 2020 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...
11,088
40.68797
115
py
robust-transformers
robust-transformers-main/utils/notification_service.py
# Copyright 2020 The HuggingFace 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 required by applicabl...
27,052
36.730823
126
py
robust-transformers
robust-transformers-main/utils/check_repo.py
# coding=utf-8 # Copyright 2020 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...
30,085
39.656757
141
py
robust-transformers
robust-transformers-main/utils/update_metadata.py
# coding=utf-8 # Copyright 2021 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...
10,573
42.875519
117
py
robust-transformers
robust-transformers-main/utils/check_dummies.py
# coding=utf-8 # Copyright 2020 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...
6,086
35.449102
118
py
robust-transformers
robust-transformers-main/utils/print_env_pt.py
#!/usr/bin/env python3 # coding=utf-8 # Copyright 2020 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 # # Unles...
1,006
33.724138
74
py
robust-transformers
robust-transformers-main/utils/check_table.py
# coding=utf-8 # Copyright 2020 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...
9,799
41.060086
118
py
robust-transformers
robust-transformers-main/utils/notification_service_deprecated.py
# Copyright 2020 The HuggingFace 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 required by applicabl...
8,174
36.5
127
py
robust-transformers
robust-transformers-main/utils/test_module/custom_modeling.py
import torch from transformers import PreTrainedModel from .custom_configuration import CustomConfig, NoSuperInitConfig class CustomModel(PreTrainedModel): config_class = CustomConfig def __init__(self, config): super().__init__(config) self.linear = torch.nn.Linear(config.hidden_size, conf...
772
21.735294
77
py
TileTrans
TileTrans-main/reconstructor.py
from typing import Union, List, Dict, Any import torch import torchvision import torch.nn as nn import torchvision.transforms as transforms import torchvision.datasets as datasets import torchvision.models as models import torch.utils.data as Data import common from metrics import Metrics, MetricsL1, MetricsGradient f...
7,797
47.7375
153
py
TileTrans
TileTrans-main/pruner.py
import os from typing import List, Any from itertools import zip_longest import torch from torch.nn import modules from torch.utils.data.dataloader import DataLoader import torchvision import torch.nn as nn import torch.utils.data as Data import torchvision.transforms as transforms import torchvision.models as models ...
9,324
42.574766
153
py
TileTrans
TileTrans-main/common.py
import torch import torchvision import torch.nn as nn import torchvision.models as models import torch.utils.data as Data import numpy as np import matplotlib.pyplot as plt import sys import torchvision.transforms as transforms import torchvision.datasets as datasets def print_model_weight(net): for layer in net.c...
3,712
37.278351
155
py
TileTrans
TileTrans-main/metrics.py
import os from typing import List, Any import torch import torch.nn as nn from common import get_layers class Metrics(): pass class MetricsL1(Metrics): @staticmethod def eval(layer: nn.Module, *agrs: Any, **kargs: Any): return torch.abs(layer.weight) @staticmethod def hook_func(*args...
1,626
26.576271
82
py
TileTrans
TileTrans-main/train.py
import torch import torchvision import torch.nn as nn import torch.utils.data as Data import torch.distributed as dist import numpy as np import matplotlib.pyplot as plt import torchvision.models as models import torchvision.transforms as transforms GPU_NUM=2 def check_correct_rate(net, test_loader): correct_num ...
3,058
30.214286
136
py
speechbrain
speechbrain-main/setup.py
#!/usr/bin/env python3 import os import sys import site import setuptools from distutils.core import setup # Editable install in user site directory can be allowed with this hack: # https://github.com/pypa/pip/issues/7953. site.ENABLE_USER_SITE = "--user" in sys.argv[1:] with open("README.md") as f: long_descrip...
1,280
25.6875
72
py
speechbrain
speechbrain-main/tools/profiling/profile.py
"""Example recipe to benchmark SpeechBrain using PyTorch profiling. A pretrained interference is benchmarked for real-time factors and memory peaks across audio durations and batch sizes. Profiling is carried out either on random data (pure noise) or on an example file that is truncated and repeated to be representati...
13,246
32.45202
119
py
speechbrain
speechbrain-main/speechbrain/core.py
"""Core SpeechBrain code for running experiments. Authors * Peter Plantinga 2020 * Abdel Heba 2020 * Mirco Ravanelli 2020 * Aku Rouhe 2021 * Andreas Nautsch 2022 """ import os import sys import yaml import time import torch import shutil import logging import inspect import pathlib import argparse import tempfil...
54,493
36.608006
102
py
speechbrain
speechbrain-main/speechbrain/tokenizers/SentencePiece.py
"""Library for Byte-pair-encoding (BPE) tokenization. Authors * Abdelwahab Heba 2020 * Loren Lugosch 2020 """ import os.path import torch import logging import csv import json import sentencepiece as spm from speechbrain.dataio.dataio import merge_char from speechbrain.utils import edit_distance from speechbrain.uti...
19,212
40.229614
119
py
speechbrain
speechbrain-main/speechbrain/decoders/seq2seq.py
"""Decoding methods for seq2seq autoregressive model. Authors * Adel Moumen 2022 * Ju-Chieh Chou 2020 * Peter Plantinga 2020 * Mirco Ravanelli 2020 * Sung-Lin Yeh 2020 """ import torch import speechbrain as sb from speechbrain.decoders.ctc import CTCPrefixScorer class S2SBaseSearcher(torch.nn.Module): """S...
56,679
33.560976
121
py
speechbrain
speechbrain-main/speechbrain/decoders/ctc.py
"""Decoders and output normalization for CTC. Authors * Mirco Ravanelli 2020 * Aku Rouhe 2020 * Sung-Lin Yeh 2020 """ import torch from itertools import groupby from speechbrain.dataio.dataio import length_to_mask class CTCPrefixScorer: """This class implements the CTC prefix scorer of Algorithm 2 in refe...
13,350
34.413793
119
py
speechbrain
speechbrain-main/speechbrain/decoders/transducer.py
"""Decoders and output normalization for Transducer sequence. Author: Abdelwahab HEBA 2020 Sung-Lin Yeh 2020 """ import torch from functools import partial class TransducerBeamSearcher(torch.nn.Module): """ This class implements the beam-search algorithm for the transducer model. Parameters ...
19,715
35.309392
111
py
speechbrain
speechbrain-main/speechbrain/wordemb/transformer.py
""" A convenience wrapper for word embeddings retrieved out of HuggingFace transformers (e.g. BERT) Authors * Artem Ploujnikov 2021 """ import torch import numpy as np from torch import nn def _last_n_layers(count): return range(-count, 0) class TransformerWordEmbeddings(nn.Module): """A wrapper to retri...
9,176
30.003378
92
py
speechbrain
speechbrain-main/speechbrain/wordemb/util.py
""" Utilities for word embeddings Authors * Artem Ploujnikov 2021 """ import torch def expand_to_chars(emb, seq, seq_len, word_separator): """Expands word embeddings to a sequence of character embeddings, assigning each character the word embedding of the word to which it belongs Arguments -----...
2,076
25.974026
76
py
speechbrain
speechbrain-main/speechbrain/nnet/embedding.py
"""Library implementing embedding. Authors * Abdelwahab Heba 2020 """ import torch import logging import torch.nn as nn logger = logging.getLogger(__name__) class Embedding(nn.Module): """Computes an embedding x = wx. Arguments --------- num_embeddings : int Size of the dictionary of embe...
3,928
33.165217
120
py
speechbrain
speechbrain-main/speechbrain/nnet/pooling.py
"""Library implementing pooling. Authors * Titouan Parcollet 2020 * Mirco Ravanelli 2020 * Nauman Dawalatabad 2020 * Jianyuan Zhong 2020 * Sarthak Yadav 2022 """ import torch import logging import torch.nn as nn import torch.nn.functional as F logger = logging.getLogger(__name__) class Pooling1d(nn.Module): ...
16,006
29.316288
114
py
speechbrain
speechbrain-main/speechbrain/nnet/losses.py
""" Losses for training neural networks. Authors * Mirco Ravanelli 2020 * Samuele Cornell 2020 * Hwidong Na 2020 * Yan Gao 2020 * Titouan Parcollet 2020 """ import math import torch import logging import functools import numpy as np import torch.nn as nn import torch.nn.functional as F from itertools import perm...
40,423
31.28754
117
py
speechbrain
speechbrain-main/speechbrain/nnet/CNN.py
"""Library implementing convolutional neural networks. Authors * Mirco Ravanelli 2020 * Jianyuan Zhong 2020 * Cem Subakan 2021 * Davide Borra 2021 * Andreas Nautsch 2022 * Sarthak Yadav 2022 """ import math import torch import logging import numpy as np import torch.nn as nn import torch.nn.functional as F impo...
47,329
30.261559
117
py
speechbrain
speechbrain-main/speechbrain/nnet/schedulers.py
""" Schedulers for updating hyperparameters (such as learning rate). Authors * Mirco Ravanelli 2020 * Peter Plantinga 2020 * Loren Lugosch 2020 """ import math import torch import logging from speechbrain.utils import checkpoints logger = logging.getLogger(__name__) def update_learning_rate(optimizer, new_lr, ...
35,940
31.379279
119
py
speechbrain
speechbrain-main/speechbrain/nnet/quantisers.py
""" Gumbel Softmax implementation with multiple groups possible. Authors * Rudolf A. Braun 2022 """ import torch import torch.nn as nn import torch.nn.functional as F class GumbelVectorQuantizer(nn.Module): """Vector quantization using gumbel softmax. Copied from fairseq implementation. Arguments -----...
3,699
28.83871
104
py
speechbrain
speechbrain-main/speechbrain/nnet/RNN.py
"""Library implementing recurrent neural networks. Authors * Mirco Ravanelli 2020 * Ju-Chieh Chou 2020 * Jianyuan Zhong 2020 * Loren Lugosch 2020 """ import torch import logging import torch.nn as nn from speechbrain.nnet.attention import ( ContentBasedAttention, LocationAwareAttention, KeyValueAttent...
49,939
29.999379
82
py
speechbrain
speechbrain-main/speechbrain/nnet/linear.py
"""Library implementing linear transformation. Authors * Mirco Ravanelli 2020 * Davide Borra 2021 """ import torch import logging import torch.nn as nn logger = logging.getLogger(__name__) class Linear(torch.nn.Module): """Computes a linear transformation y = wx + b. Arguments --------- n_neuron...
3,506
27.056
107
py
speechbrain
speechbrain-main/speechbrain/nnet/dropout.py
"""Library implementing dropout. Authors * Mirco Ravanelli 2020 """ import torch # noqa: F401 import logging import torch.nn as nn logger = logging.getLogger(__name__) class Dropout2d(nn.Module): """This function implements dropout 2d. It randomly put zeros on entire channels. Arguments --------...
1,320
22.175439
72
py
speechbrain
speechbrain-main/speechbrain/nnet/activations.py
"""Library implementing activation functions. Authors * Mirco Ravanelli 2020 * Jianyuan Zhong 2020 """ import torch import logging import torch.nn.functional as F logger = logging.getLogger(__name__) class Softmax(torch.nn.Module): """Computes the softmax of a 2d, 3d, or 4d input tensor. Arguments -...
3,474
23.300699
144
py
speechbrain
speechbrain-main/speechbrain/nnet/normalization.py
"""Library implementing normalization. Authors * Mirco Ravanelli 2020 * Guillermo Cámbara 2021 * Sarthak Yadav 2022 """ import torch import torch.nn as nn class BatchNorm1d(nn.Module): """Applies 1d batch normalization to the input tensor. Arguments --------- input_shape : tuple The expec...
18,623
28.942122
118
py
speechbrain
speechbrain-main/speechbrain/nnet/attention.py
"""Library implementing attention modules. Authors * Ju-Chieh Chou 2020 * Jianyuan Zhong 2020 * Loren Lugosch 2020 * Samuele Cornell 2020 """ import torch import logging import torch.nn as nn import numpy as np from typing import Optional from speechbrain.dataio.dataio import length_to_mask import torch.nn.functi...
28,426
32.841667
149
py
speechbrain
speechbrain-main/speechbrain/nnet/containers.py
"""Library for implementing cascade (sequences) of different neural modules. Authors * Peter Plantinga 2020 """ import torch import inspect import logging import operator import functools from speechbrain.nnet.linear import Linear from speechbrain.utils.callchains import lengths_arg_exists logger = logging.getLogge...
13,475
33.911917
80
py
speechbrain
speechbrain-main/speechbrain/nnet/complex_networks/c_CNN.py
"""Library implementing complex-valued convolutional neural networks. Authors * Titouan Parcollet 2020 """ import torch import torch.nn as nn import logging import torch.nn.functional as F from speechbrain.nnet.CNN import get_padding_elem from speechbrain.nnet.complex_networks.c_ops import ( unitary_init, com...
14,753
29.995798
95
py
speechbrain
speechbrain-main/speechbrain/nnet/complex_networks/c_normalization.py
"""Library implementing complex-valued normalization. Authors * Titouan Parcollet 2020 """ import torch from torch.nn import Parameter import numpy as np from speechbrain.nnet.complex_networks.c_ops import multi_mean class CBatchNorm(torch.nn.Module): """This class is implements the complex-valued batch-normal...
26,368
34.730352
80
py
speechbrain
speechbrain-main/speechbrain/nnet/complex_networks/c_ops.py
"""This library implements different operations needed by complex- valued architectures. This work is inspired by: "Deep Complex Networks" from Trabelsi C. et al. Authors * Titouan Parcollet 2020 """ import torch import torch.nn.functional as F import numpy as np def check_complex_input(input_shape): """Che...
9,840
29.28
80
py
speechbrain
speechbrain-main/speechbrain/nnet/complex_networks/c_RNN.py
"""Library implementing complex-valued recurrent neural networks. Authors * Titouan Parcollet 2020 """ import torch import logging from speechbrain.nnet.complex_networks.c_linear import CLinear from speechbrain.nnet.complex_networks.c_normalization import ( CBatchNorm, CLayerNorm, ) logger = logging.getLogg...
38,455
31.153846
97
py
speechbrain
speechbrain-main/speechbrain/nnet/complex_networks/c_linear.py
"""Library implementing complex-valued linear transformation. Authors * Titouan Parcollet 2020 """ import torch import logging from speechbrain.nnet.complex_networks.c_ops import ( affect_init, complex_init, unitary_init, complex_linear_op, check_complex_input, ) logger = logging.getLogger(__nam...
4,020
32.508333
97
py
speechbrain
speechbrain-main/speechbrain/nnet/transducer/transducer_joint.py
"""Library implementing transducer_joint. Author Abdelwahab HEBA 2020 """ import torch import logging import torch.nn as nn logger = logging.getLogger(__name__) class Transducer_joint(nn.Module): """Computes joint tensor between Transcription network (TN) & Prediction network (PN) Arguments ------...
3,106
31.364583
89
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/q_RNN.py
"""Library implementing quaternion-valued recurrent neural networks. Authors * Titouan Parcollet 2020 """ import torch import logging from speechbrain.nnet.quaternion_networks.q_linear import QLinear from speechbrain.nnet.quaternion_networks.q_normalization import QBatchNorm from torch import Tensor from typing impo...
40,503
32.06449
94
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/q_CNN.py
"""Library implementing quaternion-valued convolutional neural networks. Authors * Titouan Parcollet 2020 """ import torch import torch.nn as nn import logging import torch.nn.functional as F from speechbrain.nnet.CNN import get_padding_elem from speechbrain.nnet.quaternion_networks.q_ops import ( unitary_init, ...
20,523
32.980132
94
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/q_ops.py
"""This library implements different operations needed by quaternion- valued architectures. This work is inspired by: "Quaternion neural networks" - Parcollet T. "Quaternion recurrent neural networks" - Parcollet T. et al. "Quaternion convolutional neural networks for end-to-end automatic speech recognition" - Parcolle...
28,142
33.362637
80
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/q_normalization.py
"""Library implementing quaternion-valued normalization. Authors * Titouan Parcollet 2020 """ import torch from torch.nn import Parameter class QBatchNorm(torch.nn.Module): """This class implements the simplest form of a quaternion batchnorm as described in : "Quaternion Convolutional Neural Network for ...
5,396
31.908537
89
py
speechbrain
speechbrain-main/speechbrain/nnet/quaternion_networks/q_linear.py
"""Library implementing quaternion-valued linear transformation. Authors * Titouan Parcollet 2020 """ import torch import logging from speechbrain.nnet.quaternion_networks.q_ops import ( affect_init, unitary_init, quaternion_init, quaternion_linear_op, check_quaternion_input, quaternion_linea...
7,965
34.721973
94
py
speechbrain
speechbrain-main/speechbrain/nnet/loss/transducer_loss.py
""" Transducer loss implementation (depends on numba) Authors * Abdelwahab Heba 2020 """ import torch from torch.autograd import Function from torch.nn import Module try: from numba import cuda except ImportError: err_msg = "The optional dependency Numba is needed to use this module\n" err_msg += "Canno...
14,074
38.985795
167
py
speechbrain
speechbrain-main/speechbrain/nnet/loss/stoi_loss.py
"""Library for computing STOI computation. Reference: "End-to-End Waveform Utterance Enhancement for Direct Evaluation Metrics Optimization by Fully Convolutional Neural Networks", TASLP, 2018 Authors: Szu-Wei, Fu 2020 """ import torch import torchaudio import numpy as np from speechbrain.utils.torch_audio_backen...
6,489
28.770642
76
py
speechbrain
speechbrain-main/speechbrain/nnet/loss/guidedattn_loss.py
"""The Guided Attention Loss implementation This loss can be used to speed up the training of models in which the correspondence between inputs and outputs is roughly linear, and the attention alignments are expected to be approximately diagonal, such as Grapheme-to-Phoneme and Text-to-Speech Authors * Artem Ploujnik...
5,760
31.184358
87
py
speechbrain
speechbrain-main/speechbrain/nnet/loss/si_snr_loss.py
""" # Authors: * Szu-Wei, Fu 2021 * Mirco Ravanelli 2020 * Samuele Cornell 2020 * Hwidong Na 2020 * Yan Gao 2020 * Titouan Parcollet 2020 """ import torch import numpy as np smallVal = np.finfo("float").eps # To avoid divide by zero def si_snr_loss(y_pred_batch, y_true_batch, lens, reduction="mean"): """...
1,912
27.132353
78
py
speechbrain
speechbrain-main/speechbrain/pretrained/interfaces.py
"""Defines interfaces for simple inference with pretrained models Authors: * Aku Rouhe 2021 * Peter Plantinga 2021 * Loren Lugosch 2020 * Mirco Ravanelli 2020 * Titouan Parcollet 2021 * Abdel Heba 2021 * Andreas Nautsch 2022 * Pooneh Mousavi 20023 """ import logging import hashlib import sys import speechbrain...
107,365
34.812542
122
py
speechbrain
speechbrain-main/speechbrain/dataio/legacy.py
"""SpeechBrain Extended CSV Compatibility.""" from speechbrain.dataio.dataset import DynamicItemDataset import collections import csv import pickle import logging import torch import torchaudio import re logger = logging.getLogger(__name__) TORCHAUDIO_FORMATS = ["wav", "flac", "aac", "ogg", "flac", "mp3"] ITEM_POSTF...
10,629
32.533123
79
py
speechbrain
speechbrain-main/speechbrain/dataio/dataio.py
""" Data reading and writing. Authors * Mirco Ravanelli 2020 * Aku Rouhe 2020 * Ju-Chieh Chou 2020 * Samuele Cornell 2020 * Abdel HEBA 2020 * Gaelle Laperriere 2021 * Sahar Ghannay 2021 * Sylvain de Langen 2022 """ import os import torch import logging import numpy as np import pickle import hashlib import csv...
34,200
28.560069
187
py