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
pytorch
pytorch-main/torchgen/api/types/types_base.py
""" Where should I add a new type? `types_base.py` vs `types.py` This file defines data model classes for torchgen typing system, as well as some base types such as int32_t. `types.py` defines ATen Tensor type and some c10 types, along with signatures that use these types. The difference between these two files, is ...
8,872
32.108209
114
py
pytorch
pytorch-main/torchgen/shape_functions/gen_jit_shape_functions.py
#!/usr/bin/env python3 import importlib.util import os import sys from itertools import chain from pathlib import Path # Manually importing the shape function module based on current directory # instead of torch imports to avoid needing to recompile Pytorch before # running the script file_path = Path.cwd() / "torch...
5,141
27.098361
86
py
pytorch
pytorch-main/torchgen/operator_versions/gen_mobile_upgraders_constant.py
MOBILE_UPGRADERS_HEADER_DESCRIPTION = """/** * @generated * This is an auto-generated file. Please do not modify it by hand. * To re-generate, please run: * cd ~/pytorch && python torchgen/operator_versions/gen_mobile_upgraders.py */ """
243
29.5
76
py
pytorch
pytorch-main/torchgen/operator_versions/gen_mobile_upgraders.py
#!/usr/bin/env python3 import os from enum import Enum from pathlib import Path from typing import Any, Dict, List import torch from torch.jit.generate_bytecode import generate_upgraders_bytecode from torchgen.code_template import CodeTemplate from torchgen.operator_versions.gen_mobile_upgraders_constant import ( ...
12,671
31.244275
114
py
pytorch
pytorch-main/torchgen/decompositions/gen_jit_decompositions.py
#!/usr/bin/env python3 import os from pathlib import Path from torch.jit._decompositions import decomposition_table # from torchgen.code_template import CodeTemplate DECOMP_HEADER = r""" /** * @generated * This is an auto-generated file. Please do not modify it by hand. * To re-generate, please run: * cd ~/pytor...
2,375
24.010526
82
py
pytorch
pytorch-main/torchgen/dest/lazy_ir.py
import itertools from abc import ABC from dataclasses import dataclass from typing import Any, Dict, List, Optional, Tuple, Union import torchgen.api.dispatcher as dispatcher from torchgen.api.lazy import ( getValueT, isValueType, LazyArgument, LazyIrProperties, LazyIrSchema, tensorListValueT, ...
29,273
40.28914
129
py
pytorch
pytorch-main/torchgen/dest/register_dispatch_key.py
import itertools import textwrap from dataclasses import dataclass from typing import List, Literal, Optional, Tuple, Union import torchgen.api.cpp as cpp import torchgen.api.meta as meta import torchgen.api.structured as structured from torchgen.api.translate import translate from torchgen.api.types import ( Base...
40,487
39.814516
132
py
pytorch
pytorch-main/torchgen/dest/lazy_ts_lowering.py
from torchgen.api.lazy import LazyArgument, LazyIrSchema from torchgen.api.types import OptionalCType def ts_lowering_body(schema: LazyIrSchema) -> str: # for now, we just want one IR class decl and soon after also the method defs # and we use the functional version not out/inplace. emplace_arguments = []...
1,831
36.387755
124
py
pytorch
pytorch-main/torchgen/dest/native_functions.py
from typing import List, Optional, Union import torchgen.api.meta as meta import torchgen.api.structured as structured from torchgen.api.types import kernel_signature from torchgen.context import with_native_function_and_index from torchgen.model import BackendIndex, NativeFunction, NativeFunctionsGroup from torchgen...
2,328
34.830769
88
py
pytorch
pytorch-main/torchgen/dest/ufunc.py
from dataclasses import dataclass from typing import Dict, List, Optional, Sequence, Tuple, Union import torchgen.api.ufunc as ufunc from torchgen.api.translate import translate from torchgen.api.types import ( BaseCType, Binding, CType, Expr, NamedCType, opmath_t, scalar_t, StructuredI...
17,800
31.602564
116
py
pytorch
pytorch-main/torchgen/selective_build/operator.py
from dataclasses import dataclass from typing import Dict, Optional, Tuple # This class holds information about a single operator used to determine # the outcome of a selective/custom PyTorch build that doesn't include # registration code for all the supported operators. This is done to # reduce the size of the gener...
6,564
36.729885
98
py
pytorch
pytorch-main/torchgen/selective_build/selector.py
from collections import defaultdict from collections.abc import Iterable from dataclasses import dataclass from typing import Dict, List, Optional, Set, Tuple import yaml from torchgen.model import NativeFunction from torchgen.selective_build.operator import ( merge_debug_info, merge_operator_dicts, Selec...
12,606
35.227011
105
py
pytorch
pytorch-main/torchgen/static_runtime/gen_static_runtime_ops.py
import argparse import itertools import os from typing import Sequence, TypeVar, Union from libfb.py.log import set_simple_logging # type: ignore[import] from torchgen import gen from torchgen.context import native_function_manager from torchgen.model import DispatchKey, NativeFunctionsGroup, NativeFunctionsViewGrou...
7,353
31.113537
88
py
pytorch
pytorch-main/torchgen/static_runtime/config.py
from typing import Dict, Union from torchgen.model import NativeFunctionsGroup, NativeFunctionsViewGroup def func_name_base_str(g: Union[NativeFunctionsGroup, NativeFunctionsViewGroup]) -> str: if isinstance(g, NativeFunctionsGroup): return str(g.functional.func.name.name.base) else: return s...
14,493
36.25964
88
py
pytorch
pytorch-main/torchgen/static_runtime/generator.py
import json import logging import math from typing import Dict, List, Optional, Sequence, Tuple, Union import torchgen.api.cpp as cpp from torchgen.context import native_function_manager from torchgen.model import ( Argument, BackendIndex, BaseTy, BaseType, FunctionSchema, NativeFunctionsGroup...
26,374
32.092848
122
py
DiagnoseRE
DiagnoseRE-master/test.py
import torch import json import pickle import opennre from opennre import encoder, model, framework import sys import os import argparse import logging logging.basicConfig(level=logging.INFO) # Silent unimportant log messages for logger_name in ['transformers.configuration_utils', 'transformers.mo...
2,497
32.756757
84
py
DiagnoseRE
DiagnoseRE-master/train.py
import torch import json import pickle import opennre from opennre import encoder, model, framework import sys import os import argparse import logging logging.basicConfig(level=logging.INFO) # Silent unimportant log messages for logger_name in ['transformers.configuration_utils', 'transformers.mo...
2,914
35.4375
84
py
DiagnoseRE
DiagnoseRE-master/Q2/victim.py
import sys import os import re import json import logging import OpenAttack import numpy as np import opennre import torch import argparse from opennre.model import SoftmaxNN from OpenAttack.utils.dataset import Dataset, DataInstance from tqdm import tqdm import logging import tensorflow as tf class REClassifier(Open...
6,497
34.124324
110
py
DiagnoseRE
DiagnoseRE-master/Q2/attack.py
import time from multiprocessing import Queue, Process, set_start_method from victim import * # Enable this to allow tensors being converted to numpy arrays tf.compat.v1.enable_eager_execution() try: set_start_method('spawn') except Exception: pass logging.basicConfig(level=logging.INFO) # Silent unimportant ...
5,707
39.771429
113
py
DiagnoseRE
DiagnoseRE-master/Q2/filter_correct.py
from victim import * logging.basicConfig(level=logging.INFO) # Silent unimportant log messages for logger_name in ['transformers.configuration_utils', 'transformers.modeling_utils', 'transformers.tokenization_utils_base']: logging.getLogger(logger_name).setLevel(logging.WARN...
1,963
40.787234
84
py
DiagnoseRE
DiagnoseRE-master/Q1/random_perturb.py
import os import argparse import json import nltk from collections import deque from tqdm import tqdm import random import logging import checklist import torch import spacy from checklist.perturb import Perturb # from checklist.editor import Editor spacy_model_path = 'en_core_web_sm-2.3.1/en_core_web_sm/en_core_web_s...
7,255
39.764045
102
py
DiagnoseRE
DiagnoseRE-master/Q3/integrated_gradient.py
import numpy as np import torch from torch import nn import json import opennre from opennre.model import SoftmaxNN from tqdm import tqdm import sys import os import argparse import logging device = torch.device('cuda:0') logging.basicConfig(level=logging.INFO) # Silent unimportant log messages for logger_name in ['tr...
4,524
34.077519
84
py
DiagnoseRE
DiagnoseRE-master/Q3/train_cf.py
import torch import json import pickle import opennre from opennre import encoder, model, framework import sys import os import argparse import logging logging.basicConfig(level=logging.INFO) # Silent unimportant log messages for logger_name in ['transformers.configuration_utils', 'transformers.mo...
4,391
33.857143
84
py
DiagnoseRE
DiagnoseRE-master/Q3/counterfactual.py
import numpy as np import json from tqdm import tqdm import sys import torch import os import argparse import logging logging.basicConfig(level=logging.INFO) # Silent unimportant log messages for logger_name in ['transformers.configuration_utils', 'transformers.modeling_utils', ...
4,346
41.203883
106
py
DiagnoseRE
DiagnoseRE-master/Q3/test_cf.py
import torch import json import pickle import opennre from opennre import encoder, model, framework import sys import os import argparse import logging logging.basicConfig(level=logging.INFO) # Silent unimportant log messages for logger_name in ['transformers.configuration_utils', 'transformers.mo...
3,911
31.6
84
py
DiagnoseRE
DiagnoseRE-master/Q4/train_weighted.py
import torch import json import pickle import opennre from opennre import encoder, model, framework import sys import os import argparse import logging import math from torch.utils.data import WeightedRandomSampler, DataLoader logging.basicConfig(level=logging.INFO) # Silent unimportant log messages for logger_name i...
4,526
37.042017
100
py
DiagnoseRE
DiagnoseRE-master/Q5/select_debiased.py
import os import sys import json import argparse import logging import random import torch import opennre from tqdm import tqdm logging.basicConfig(level=logging.INFO) # Silent unimportant log messages for logger_name in ['transformers.configuration_utils', 'transformers.modeling_utils', ...
3,155
34.460674
90
py
sockeye
sockeye-main/test/unit/test_layers.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
11,578
40.801444
119
py
sockeye
sockeye-main/test/unit/test_average.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
3,926
46.313253
114
py
sockeye
sockeye-main/test/unit/test_scoring.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
1,290
35.885714
79
py
sockeye
sockeye-main/test/unit/test_loss.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
5,637
32.760479
94
py
sockeye
sockeye-main/test/unit/test_beam_search.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
18,551
42.858156
117
py
sockeye
sockeye-main/test/unit/test_lr_scheduler.py
# Copyright 2017--2019 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
5,453
49.036697
112
py
sockeye
sockeye-main/test/unit/test_deepspeed.py
# Copyright 2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file acc...
1,817
37.680851
108
py
sockeye
sockeye-main/test/unit/test_arguments.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
19,608
38.855691
116
py
sockeye
sockeye-main/test/unit/test_inference.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
25,031
51.698947
148
py
sockeye
sockeye-main/test/unit/test_params.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
4,963
43.321429
114
py
sockeye
sockeye-main/test/unit/test_knn.py
# Copyright 2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file acc...
7,827
43.477273
120
py
sockeye
sockeye-main/test/unit/test_quantize.py
# Copyright 2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file acc...
3,449
43.805195
113
py
sockeye
sockeye-main/test/unit/test_transformer.py
# Copyright 2018--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
1,461
34.658537
79
py
sockeye
sockeye-main/test/unit/test_data_io.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
40,171
48.110024
118
py
sockeye
sockeye-main/test/unit/test_utils.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
20,867
47.417633
118
py
sockeye
sockeye-main/test/integration/test_seq_copy_int.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
15,783
52.144781
116
py
sockeye
sockeye-main/sockeye/inference.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
69,919
52.455657
473
py
sockeye
sockeye-main/sockeye/lr_scheduler.py
# Copyright 2017--2019 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
12,233
41.926316
120
py
sockeye
sockeye-main/sockeye/scoring.py
# Copyright 2018--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
9,314
47.015464
126
py
sockeye
sockeye-main/sockeye/average.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
5,742
33.184524
117
py
sockeye
sockeye-main/sockeye/arguments.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
82,594
53.018967
122
py
sockeye
sockeye-main/sockeye/constants.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
13,965
34.090452
122
py
sockeye
sockeye-main/sockeye/checkpoint_decoder.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
11,359
46.731092
117
py
sockeye
sockeye-main/sockeye/optimizers.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
3,278
36.689655
118
py
sockeye
sockeye-main/sockeye/nvs.py
# Copyright 2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file acc...
2,055
37.792453
118
py
sockeye
sockeye-main/sockeye/loss.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
15,168
37.113065
145
py
sockeye
sockeye-main/sockeye/embeddings.py
# Copyright 2017--2021 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
5,152
37.455224
119
py
sockeye
sockeye-main/sockeye/training.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
49,875
47.51751
129
py
sockeye
sockeye-main/sockeye/utils.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
29,031
34.404878
122
py
sockeye
sockeye-main/sockeye/model.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
42,829
49.566706
119
py
sockeye
sockeye-main/sockeye/encoder.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
9,165
38.852174
132
py
sockeye
sockeye-main/sockeye/convert_deepspeed.py
# Copyright 2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file acc...
5,580
44.008065
120
py
sockeye
sockeye-main/sockeye/log.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
4,642
28.01875
102
py
sockeye
sockeye-main/sockeye/beam_search.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
57,038
47.792985
129
py
sockeye
sockeye-main/sockeye/layers.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
39,877
44.315909
175
py
sockeye
sockeye-main/sockeye/generate_decoder_states.py
# Copyright 2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file acc...
12,146
41.472028
119
py
sockeye
sockeye-main/sockeye/transformer.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
16,758
45.812849
112
py
sockeye
sockeye-main/sockeye/decoder.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
14,845
46.43131
126
py
sockeye
sockeye-main/sockeye/data_io.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
100,351
47.107383
137
py
sockeye
sockeye-main/sockeye/quantize.py
# Copyright 2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file acc...
2,490
30.935897
116
py
sockeye
sockeye-main/sockeye/train.py
# Copyright 2017--2022 Amazon.com, Inc. or its affiliates. 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. A copy of the License # is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" fi...
65,203
52.184339
120
py
EvidentialSparsification
EvidentialSparsification-main/BehaviorPrediction/code/dst/run_dst.py
import numpy as np import scipy import scipy.stats import itertools import matplotlib.pyplot as plt import matplotlib.colors as colors import matplotlib.cm as cm from copy import deepcopy import pickle as pkl import os from tqdm import tqdm import matplotlib2tikz import torch from sparsemax import Sparsemax from d...
9,290
38.875536
159
py
EvidentialSparsification
EvidentialSparsification-main/BehaviorPrediction/code/dst/sparsemax.py
"""Sparsemax activation function. Pytorch implementation of Sparsemax function from: -- "From Softmax to Sparsemax: A Sparse Model of Attention and Multi-Label Classification" -- André F. T. Martins, Ramón Fernandez Astudillo (http://arxiv.org/abs/1602.02068) """ from __future__ import division import torch import t...
2,767
31.186047
90
py
EvidentialSparsification
EvidentialSparsification-main/BehaviorPrediction/code/model/dyn_stg.py
import numpy as np import torch from model.node_model import MultimodalGenerativeCVAE class SpatioTemporalGraphCVAEModel(object): def __init__(self, robot_node, model_registrar, hyperparams, log_writer, device): super(SpatioTemporalGraphCVAEModel, self).__init__() ...
11,097
47.252174
123
py
EvidentialSparsification
EvidentialSparsification-main/NotMNIST/dataloader.py
# From: https://github.com/Aftaab99/PyTorchImageClassifier/blob/master/dataloader.py import os import numpy as np import torch from PIL import Image from torch.utils.data.dataset import Dataset from scipy.misc import imread from torch import Tensor """ Loads the train/test set. Every image in the dataset is 28x28 pi...
1,718
29.696429
84
py
EvidentialSparsification
EvidentialSparsification-main/NotMNIST/utils.py
# Code modified from: https://github.com/timbmg/VAE-CVAE-MNIST/ seed = 123 import numpy as np np.random.seed(seed) import torch torch.manual_seed(seed) torch.cuda.manual_seed(seed) from torch.autograd import Variable def to_var(x, volatile=False): if torch.cuda.is_available(): x = x.cuda() return Va...
1,975
28.492537
131
py
EvidentialSparsification
EvidentialSparsification-main/NotMNIST/run_dst_training.py
'''This file computes the training evolution performance.''' import numpy as np import scipy import scipy.stats import itertools import matplotlib.pyplot as plt from copy import deepcopy import pdb from tqdm import tqdm import matplotlib2tikz import torch from dst_utils import * from dst import * import os # From:...
19,384
58.281346
218
py
EvidentialSparsification
EvidentialSparsification-main/NotMNIST/models_conv.py
# Code modified from: https://github.com/timbmg/VAE-CVAE-MNIST/ seed = 123 import numpy as np np.random.seed(seed) import torch torch.manual_seed(seed) torch.cuda.manual_seed(seed) import torch.nn as nn from sparsemax import Sparsemax from utils import to_var, idx2onehot, sample_q, sample_p class View(nn.Module): ...
7,640
37.786802
155
py
EvidentialSparsification
EvidentialSparsification-main/NotMNIST/train.py
# Code modified from: "https://github.com/timbmg/VAE-CVAE-MNIST/ # Discrete latent variable code modelled after: https://github.com/EmilienDupont/vae-concrete/ import os import time seed = 123 import numpy as np np.random.seed(seed) import torch torch.manual_seed(seed) torch.cuda.manual_seed(seed) from copy import ...
9,183
44.465347
172
py
EvidentialSparsification
EvidentialSparsification-main/NotMNIST/run_dst_bar_plot.py
'''This file computes the qualitative observations for the bar plots.''' import numpy as np import scipy import scipy.stats import itertools import matplotlib.pyplot as plt from copy import deepcopy from tqdm import tqdm import matplotlib2tikz import torch from dst_utils import * from dst import * # From: https://...
5,495
35.397351
114
py
EvidentialSparsification
EvidentialSparsification-main/FashionMNIST/run_dst_filtered_training.py
'''This file computes the training evolution performance.''' import numpy as np import scipy import scipy.stats import itertools import matplotlib.pyplot as plt from copy import deepcopy from tqdm import tqdm import matplotlib2tikz import torch from dst_utils import * from dst import * # Function from: https://git...
14,922
51.178322
204
py
EvidentialSparsification
EvidentialSparsification-main/FashionMNIST/train_tops_bottoms.py
# Code modified from: "https://github.com/timbmg/VAE-CVAE-MNIST/ # Discrete latent variable code modelled after: https://github.com/EmilienDupont/vae-concrete/ import os import time seed = 2 import numpy as np np.random.seed(seed) import torch torch.manual_seed(seed) torch.cuda.manual_seed(seed) from copy import de...
10,517
45.955357
178
py
EvidentialSparsification
EvidentialSparsification-main/FashionMNIST/utils.py
# Code modified from: https://github.com/timbmg/VAE-CVAE-MNIST/ seed = 2 import numpy as np np.random.seed(seed) import torch torch.manual_seed(seed) torch.cuda.manual_seed(seed) from torch.autograd import Variable def to_var(x, volatile=False): if torch.cuda.is_available(): x = x.cuda() return Vari...
1,973
28.462687
131
py
EvidentialSparsification
EvidentialSparsification-main/FashionMNIST/sparsemax.py
"""Sparsemax activation function. Pytorch implementation of Sparsemax function from: -- "From Softmax to Sparsemax: A Sparse Model of Attention and Multi-Label Classification" -- André F. T. Martins, Ramón Fernandez Astudillo (http://arxiv.org/abs/1602.02068) Code used from: https://github.com/gokceneraslan/SparseMax...
2,834
31.215909
90
py
EvidentialSparsification
EvidentialSparsification-main/FashionMNIST/models.py
# Code modified from: https://github.com/timbmg/VAE-CVAE-MNIST/ seed = 2 import numpy as np np.random.seed(seed) import torch torch.manual_seed(seed) torch.cuda.manual_seed(seed) import torch.nn as nn from sparsemax import Sparsemax from utils import to_var, idx2onehot, sample_q, sample_p class VAE(nn.Module): ...
4,759
29.909091
136
py
EvidentialSparsification
EvidentialSparsification-main/FashionMNIST/run_dst_bar_plot.py
'''This file computes the qualitative observations for the bar plots.''' import numpy as np import scipy import scipy.stats import itertools import matplotlib.pyplot as plt from copy import deepcopy from tqdm import tqdm import matplotlib2tikz import torch from dst_utils import * from dst import * # From: https://...
4,974
33.548611
104
py
EvidentialSparsification
EvidentialSparsification-main/MNIST/utils.py
# Code modified from: https://github.com/timbmg/VAE-CVAE-MNIST/ seed = 123 import numpy as np np.random.seed(seed) import torch torch.manual_seed(seed) torch.cuda.manual_seed(seed) from torch.autograd import Variable def to_var(x, volatile=False): if torch.cuda.is_available(): x = x.cuda() return Va...
2,012
29.5
131
py
EvidentialSparsification
EvidentialSparsification-main/MNIST/sparsemax.py
"""Sparsemax activation function. Pytorch implementation of Sparsemax function from: -- "From Softmax to Sparsemax: A Sparse Model of Attention and Multi-Label Classification" -- André F. T. Martins, Ramón Fernandez Astudillo (http://arxiv.org/abs/1602.02068) Code used from: https://github.com/gokceneraslan/SparseMax...
2,834
31.215909
90
py
EvidentialSparsification
EvidentialSparsification-main/MNIST/models.py
# Code modified from: https://github.com/timbmg/VAE-CVAE-MNIST/ seed = 123 import numpy as np np.random.seed(seed) import torch torch.manual_seed(seed) torch.cuda.manual_seed(seed) import torch.nn as nn from sparsemax import Sparsemax from utils import to_var, idx2onehot, sample_q, sample_p class VAE(nn.Module): ...
5,059
31.435897
136
py
EvidentialSparsification
EvidentialSparsification-main/MNIST/run_dst_training.py
'''This file computes the training evolution performance.''' import numpy as np import scipy import scipy.stats import itertools import matplotlib.pyplot as plt from copy import deepcopy from tqdm import tqdm import matplotlib2tikz import torch from dst_utils import * from dst import * # From: https://github.com/s...
14,365
49.230769
201
py
EvidentialSparsification
EvidentialSparsification-main/MNIST/train.py
# Code modified from: "https://github.com/timbmg/VAE-CVAE-MNIST/ # Discrete latent variable code modelled after: https://github.com/EmilienDupont/vae-concrete/ import os import time seed = 123 import numpy as np np.random.seed(seed) # original: 123, 135 import torch torch.manual_seed(seed) torch.cuda.manual_seed(see...
10,593
45.464912
178
py
EvidentialSparsification
EvidentialSparsification-main/MNIST/run_dst_bar_plot.py
'''This file computes the qualitative observations for the bar plots.''' import numpy as np import scipy import scipy.stats import itertools import matplotlib.pyplot as plt from copy import deepcopy from tqdm import tqdm import matplotlib2tikz import torch from dst_utils import * from dst import * # From: https://...
5,009
34.034965
155
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/classifier/test.py
# Code adapted from: https://github.com/huyvnphan/PyTorch_CIFAR10 import os, shutil import torch from argparse import ArgumentParser from pytorch_lightning import Trainer, seed_everything from module import MiniImagenet_Generated_Module def main(hparams): seed_everything(0) # If only train on 1 GPU. Must ...
1,620
44.027778
113
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/classifier/module.py
# Code adapted from: https://github.com/huyvnphan/PyTorch_CIFAR10 import torch import pytorch_lightning as pl import torchvision.transforms as transforms from torchvision.datasets import CIFAR10 from torch.utils.data import DataLoader from torchvision import models from datasets import MiniImagenet, get_project_root i...
7,495
53.715328
173
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/classifier/datasets.py
# Code heavily based on: https://github.com/ritheshkumar95/pytorch-vqvae import os import csv import torch.utils.data as data from PIL import Image import pdb from matplotlib import pyplot as plt from pathlib import Path def get_project_root() -> Path: """Returns project root folder.""" return Path(__file__)....
3,570
36.589474
101
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/classifier/train.py
# Code adapted from: https://github.com/huyvnphan/PyTorch_CIFAR10 import os import torch from argparse import ArgumentParser from pytorch_lightning import Trainer, seed_everything from pytorch_lightning.callbacks import LearningRateLogger from pytorch_lightning.loggers import TensorBoardLogger from module import MiniI...
2,328
42.943396
146
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/VQVAE/vqvae.py
# Code from: https://github.com/ritheshkumar95/pytorch-vqvae import numpy as np import torch import torch.nn.functional as F from torchvision import transforms, datasets from torchvision.utils import save_image, make_grid from modules import VectorQuantizedVAE, to_scalar from datasets import MiniImagenet from tensor...
8,259
39.097087
101
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/VQVAE/functions.py
# Code from: https://github.com/ritheshkumar95/pytorch-vqvae import torch from torch.autograd import Function class VectorQuantization(Function): @staticmethod def forward(ctx, inputs, codebook): with torch.no_grad(): embedding_size = codebook.size(1) inputs_size = inputs.size(...
2,561
35.6
77
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/VQVAE/vae.py
# Code from: https://github.com/ritheshkumar95/pytorch-vqvae import numpy as np import time import torch import torch.nn.functional as F from torch.distributions.normal import Normal from torchvision import datasets, transforms from torchvision.utils import save_image from modules import VAE BATCH_SIZE = 32 N_EPOC...
3,890
25.469388
85
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/VQVAE/datasets.py
# Code adapted from: https://github.com/ritheshkumar95/pytorch-vqvae import os import csv import torch.utils.data as data from PIL import Image import pdb from pathlib import Path # From: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure/40227116 def get_project_root() -> Path: ...
3,209
34.666667
103
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/VQVAE/sparsemax.py
# Code from: https://github.com/KrisKorrel/sparsemax-pytorch """Sparsemax activation function. Pytorch implementation of Sparsemax function from: -- "From Softmax to Sparsemax: A Sparse Model of Attention and Multi-Label Classification" -- André F. T. Martins, Ramón Fernandez Astudillo (http://arxiv.org/abs/1602.0206...
2,907
32.045455
100
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/VQVAE/generated_dataset.py
# Code adapted from: https://github.com/ritheshkumar95/pytorch-vqvae import numpy as np from matplotlib import pyplot as plt import torch import torch.nn.functional as F import json from torchvision import transforms, datasets from torchvision.utils import save_image, make_grid from modules import VectorQuantizedVAE,...
12,400
45.100372
180
py
EvidentialSparsification
EvidentialSparsification-main/VQVAE/VQVAE/conv_linear_test.py
import torch inputs = torch.tensor([[[[1., 2.],[3., 4.]]]]) print("linear inputs", inputs.shape) fc = torch.nn.Linear(4,2) weights = torch.tensor([[1.1, 1.2, 1.3, 1.4], [1.5, 1.6, 1.7, 1.8]]) bias = torch.tensor([1.9, 2.0]) print("linear weights", weights.shape) fc.weight.data = weights fc.bias.data = bias outp...
748
33.045455
72
py