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 |
|---|---|---|---|---|---|---|
pyserini | pyserini-master/scripts/kilt/convert_kilt_dpr_to_pyserini_format.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 3,400 | 40.47561 | 165 | py |
pyserini | pyserini-master/scripts/dkrr/encode_queries.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 3,205 | 42.324324 | 120 | py |
pyserini | pyserini-master/scripts/tct_colbert/encode_corpus_msmarco_doc.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 4,376 | 38.790909 | 117 | py |
pyserini | pyserini-master/pyserini/search/lucene/_impact_searcher.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 15,537 | 37.176904 | 140 | py |
pyserini | pyserini-master/pyserini/search/faiss/__main__.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 16,957 | 56.097643 | 145 | py |
pyserini | pyserini-master/pyserini/search/faiss/_searcher.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 27,942 | 39.090387 | 120 | py |
pyserini | pyserini-master/pyserini/search/faiss/_model.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 3,050 | 38.115385 | 99 | py |
pyserini | pyserini-master/pyserini/encode/_aggretriever.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 7,867 | 40.851064 | 159 | py |
pyserini | pyserini-master/pyserini/encode/_slim.py | import torch
from transformers import AutoModelForMaskedLM, AutoTokenizer
import numpy as np
import scipy
from pyserini.encode import QueryEncoder
class SlimQueryEncoder(QueryEncoder):
def __init__(self, model_name_or_path, tokenizer_name=None, fusion_weight=.99, device='cpu'):
self.device = device
... | 3,483 | 55.193548 | 152 | py |
pyserini | pyserini-master/pyserini/encode/_ance.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 4,589 | 37.25 | 99 | py |
pyserini | pyserini-master/pyserini/encode/_unicoil.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 7,447 | 41.318182 | 113 | py |
pyserini | pyserini-master/pyserini/encode/_splade.py | import torch
from transformers import AutoModelForMaskedLM, AutoTokenizer
import numpy as np
from pyserini.encode import QueryEncoder
class SpladeQueryEncoder(QueryEncoder):
def __init__(self, model_name_or_path, tokenizer_name=None, device='cpu'):
self.device = device
self.model = AutoModelForMa... | 1,708 | 46.472222 | 92 | py |
pyserini | pyserini-master/pyserini/encode/_base.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 7,907 | 37.764706 | 120 | py |
pyserini | pyserini-master/pyserini/encode/_tct_colbert.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 3,765 | 39.934783 | 116 | py |
pyserini | pyserini-master/pyserini/2cr/msmarco.py | #
# Pyserini: Reproducible IR research with sparse and dense representations
#
# 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... | 24,788 | 40.246256 | 135 | py |
FIREnet | FIREnet-master/firenet/ml/singlepredictor.py | import pickle
from abc import ABC, abstractmethod # abstract base class
import numpy as np
import pandas as pd
from sklearn.metrics import r2_score, mean_squared_error
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
import torch
from .modelbuilder import (build_pytorch_nnet, defa... | 12,329 | 37.895899 | 101 | py |
FIREnet | FIREnet-master/firenet/ml/modelbuilder.py | """
Helper functions to build (sklearn-compatible) predictors.
"""
import os
import torch
import skorch
from sklearn.compose import TransformedTargetRegressor
from sklearn.preprocessing import StandardScaler
ACTIVATIONS = {'sigmoid': torch.nn.Sigmoid(), 'relu': torch.nn.ReLU(),
'elu': torch.nn.ELU(), 's... | 4,740 | 38.181818 | 90 | py |
REMEDI | REMEDI-main/scripts/generate_directions.py | """Generate a bunch of REMEDI directions for analysis."""
import argparse
import logging
from typing import cast
from remedi import data, editors, models, precompute
from remedi.utils import experiment_utils, logging_utils
import baukit
import torch
import torch.utils.data
from tqdm.auto import tqdm
logger = logging... | 5,238 | 34.883562 | 88 | py |
REMEDI | REMEDI-main/scripts/eval_bias_gen.py | """Evaluate editor effects on generation for bias setting."""
import argparse
import json
import logging
from pathlib import Path
from remedi import benchmarks, data, editors, models, precompute
from remedi.utils import experiment_utils, logging_utils
import torch
logger = logging.getLogger(__name__)
def main(args... | 4,698 | 33.050725 | 87 | py |
REMEDI | REMEDI-main/scripts/eval_fact_gen.py | """Evaluate editors on the Counterfact benchmark."""
import argparse
import json
import logging
import random
from functools import partial
from pathlib import Path
from typing import cast
from remedi import benchmarks, data, editors, models, precompute
from remedi.utils import experiment_utils, logging_utils
from rem... | 11,402 | 35.315287 | 86 | py |
REMEDI | REMEDI-main/scripts/eval_bias_cls.py | """Evaluate direction classification in Bias in Bios setting."""
import argparse
import json
import logging
from pathlib import Path
from remedi import benchmarks, data, editors, models, precompute
from remedi.utils import experiment_utils, logging_utils
import torch
logger = logging.getLogger(__name__)
def main(a... | 4,879 | 33.609929 | 85 | py |
REMEDI | REMEDI-main/scripts/eval_entailment.py | """Compute before/after probabilities of concept attributes under REMEDI."""
import argparse
import json
import logging
from pathlib import Path
from remedi import benchmarks, data, editors, models, precompute
from remedi.utils import experiment_utils, logging_utils
import torch
logger = logging.getLogger(__name__)
... | 4,354 | 31.259259 | 88 | py |
REMEDI | REMEDI-main/scripts/eval_fact_mediation.py | """Evaluate how often LM mediates factual information in and out of context."""
import argparse
import json
import logging
from remedi import benchmarks, data, models
from remedi.utils import experiment_utils, logging_utils
import torch
logger = logging.getLogger(__name__)
def main(args: argparse.Namespace) -> Non... | 1,876 | 30.283333 | 79 | py |
REMEDI | REMEDI-main/scripts/train_editors.py | """Train editors."""
import argparse
import logging
from typing import cast
from remedi import data, editors, models, precompute
from remedi.utils import experiment_utils, logging_utils
from remedi.utils.typing import Dataset
import torch
logger = logging.getLogger(__name__)
def main(args: argparse.Namespace) -> N... | 4,826 | 29.550633 | 85 | py |
REMEDI | REMEDI-main/scripts/eval_fact_cls.py | """Evaluate editor's ability to classify fact mediation."""
import argparse
import json
import logging
from pathlib import Path
from remedi import benchmarks, data, editors, models, precompute
from remedi.utils import experiment_utils, logging_utils
import torch
logger = logging.getLogger(__name__)
def main(args: ... | 4,561 | 34.364341 | 84 | py |
REMEDI | REMEDI-main/tests/test_models.py | """Unit tests model_utils functions."""
from remedi import models
import pytest
import torch
def assert_equals(actual, expected, path="actual"):
"""Simple implementation of torch-friendly deep equality."""
assert type(actual) is type(expected), path
if isinstance(actual, torch.Tensor):
assert act... | 1,470 | 34.878049 | 66 | py |
REMEDI | REMEDI-main/tests/test_precompute.py | """Unit tests for precompute functions."""
from remedi import precompute
import pytest
import torch
@pytest.mark.parametrize(
"token_ranges,expected",
(
([[0, 1]], [[0, 1]]),
([[1, 3]], [[2, 3]]),
([[0, 1], [1, 3]], [[0, 1], [2, 3]]),
),
)
def test_last_token_ranges_from_batch(tok... | 1,080 | 28.216216 | 80 | py |
REMEDI | REMEDI-main/remedi/benchmarks.py | """Standalone functions for benchmarking editor performance across metrics."""
import logging
import random
from collections import OrderedDict, defaultdict
from dataclasses import dataclass
from itertools import chain
from typing import Any, Callable, Sequence, cast
from remedi import data, editors, metrics, models, ... | 56,148 | 33.299939 | 117 | py |
REMEDI | REMEDI-main/remedi/precompute.py | """Logic for getting and mucking with model hidden representations."""
import argparse
from functools import partial
from typing import Any, Literal, Optional, Sequence, cast, overload
from remedi import data, models
from remedi.utils import tokenizer_utils
from remedi.utils.typing import (
Dataset,
Device,
... | 30,331 | 31.75594 | 88 | py |
REMEDI | REMEDI-main/remedi/editors.py | """Editing models."""
import argparse
import contextlib
import logging
from collections import defaultdict
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Callable, DefaultDict, Literal, Optional, cast
from remedi import data, models, precompute
from remedi.utils import tokenizer_uti... | 46,399 | 35.278342 | 88 | py |
REMEDI | REMEDI-main/remedi/models.py | """Functions for loading and interacting with pretrained language models.
This module is designed to house all the annoying branching logic
that comes with supporting analysis of many slightly different model
implementations.
"""
import argparse
import logging
from contextlib import contextmanager
from dataclasses imp... | 7,971 | 29.427481 | 82 | py |
REMEDI | REMEDI-main/remedi/utils/typing.py | """Some useful type aliases relevant to this project."""
import pathlib
from typing import Sequence
import datasets
import numpy
import torch
import transformers
import transformers.modeling_outputs
ArrayLike = list | tuple | numpy.ndarray | torch.Tensor
PathLike = str | pathlib.Path
Device = str | torch.device
# Th... | 1,089 | 33.0625 | 85 | py |
REMEDI | REMEDI-main/remedi/utils/training_utils.py | """Utilities for training models."""
from typing import Sequence, Sized, cast
import torch
from torch.utils import data
class EarlyStopping:
"""Observes a numerical value and determines when it has not improved."""
def __init__(self, patience: int = 4, decreasing: bool = True):
"""Initialize the ear... | 3,694 | 29.791667 | 83 | py |
REMEDI | REMEDI-main/remedi/utils/experiment_utils.py | """Utilities for managing experiment runtimes and results."""
import argparse
import json
import logging
import random
import shutil
import time
from dataclasses import dataclass
from pathlib import Path
from remedi.utils import env_utils
from remedi.utils.typing import PathLike
import numpy
import torch
logger = lo... | 3,873 | 27.277372 | 87 | py |
ts2vec | ts2vec-main/ts2vec.py | import torch
import torch.nn.functional as F
from torch.utils.data import TensorDataset, DataLoader
import numpy as np
from models import TSEncoder
from models.losses import hierarchical_contrastive_loss
from utils import take_per_row, split_with_nan, centerize_vary_length_series, torch_pad_nan
import math
class TS2Ve... | 14,350 | 43.846875 | 263 | py |
ts2vec | ts2vec-main/utils.py | import os
import numpy as np
import pickle
import torch
import random
from datetime import datetime
def pkl_save(name, var):
with open(name, 'wb') as f:
pickle.dump(var, f)
def pkl_load(name):
with open(name, 'rb') as f:
return pickle.load(f)
def torch_pad_nan(arr, left=0, right=0, dim=0)... | 3,954 | 29.658915 | 81 | py |
ts2vec | ts2vec-main/train.py | import torch
import numpy as np
import argparse
import os
import sys
import time
import datetime
from ts2vec import TS2Vec
import tasks
import datautils
from utils import init_dl_program, name_with_datetime, pkl_save, data_dropout
def save_checkpoint_callback(
save_every=1,
unit='epoch'
):
assert unit in (... | 7,094 | 47.265306 | 253 | py |
ts2vec | ts2vec-main/models/losses.py | import torch
from torch import nn
import torch.nn.functional as F
def hierarchical_contrastive_loss(z1, z2, alpha=0.5, temporal_unit=0):
loss = torch.tensor(0., device=z1.device)
d = 0
while z1.size(1) > 1:
if alpha != 0:
loss += alpha * instance_contrastive_loss(z1, z2)
if d >=... | 1,874 | 35.764706 | 76 | py |
ts2vec | ts2vec-main/models/encoder.py | import torch
from torch import nn
import torch.nn.functional as F
import numpy as np
from .dilated_conv import DilatedConvEncoder
def generate_continuous_mask(B, T, n=5, l=0.1):
res = torch.full((B, T), True, dtype=torch.bool)
if isinstance(n, float):
n = int(n * T)
n = max(min(n, T // 2), 1)
... | 2,479 | 32.513514 | 96 | py |
ts2vec | ts2vec-main/models/dilated_conv.py | import torch
from torch import nn
import torch.nn.functional as F
import numpy as np
class SamePadConv(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, dilation=1, groups=1):
super().__init__()
self.receptive_field = (kernel_size - 1) * dilation + 1
padding = self.rece... | 1,921 | 33.321429 | 114 | py |
mammoth | mammoth-master/backbone/MNISTMLP_PNN.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from typing import List
import torch
import torch.nn as nn
imp... | 3,867 | 34.163636 | 112 | py |
mammoth | mammoth-master/backbone/EfficientNet.py | # Author: lukemelas (github username)
# Github repo: https://github.com/lukemelas/EfficientNet-PyTorch
# With adjustments and added comments by workingcoder (github username).
import collections
import math
import re
from functools import partial
import torch
from torch import nn
from torch.nn import functional as F
... | 40,305 | 38.710345 | 126 | py |
mammoth | mammoth-master/backbone/MNISTMLP.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from backbone import Mammot... | 2,014 | 28.202899 | 112 | py |
mammoth | mammoth-master/backbone/__init__.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import torch
import torch.nn as nn
def xavier(m:... | 3,139 | 30.089109 | 112 | py |
mammoth | mammoth-master/backbone/ResNet18.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from typing import List
import torch
import torch.nn as nn
imp... | 5,692 | 34.58125 | 112 | py |
mammoth | mammoth-master/backbone/ResNet18_PNN.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from typing import List
import torch
import torch.nn as nn
imp... | 6,355 | 37.05988 | 112 | py |
mammoth | mammoth-master/backbone/utils/modules.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from torch.nn.parameter import Pa... | 1,524 | 27.773585 | 107 | py |
mammoth | mammoth-master/models/mer.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from models.utils.continual_model import Continua... | 3,343 | 38.809524 | 113 | py |
mammoth | mammoth-master/models/gss.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from models.utils.continual_model import ContinualMode... | 2,920 | 36.935065 | 107 | py |
mammoth | mammoth-master/models/hal.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import sys
import numpy as np
import torch
from datasets impor... | 6,379 | 37.666667 | 126 | py |
mammoth | mammoth-master/models/gem.py | # Copyright 2017-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the gem_license file in the root of this source tree.
import numpy as np
import torch
try:
import quadprog
except BaseException:
print('Warning: GEM and A-GEM cannot... | 6,164 | 35.47929 | 99 | py |
mammoth | mammoth-master/models/agem_r.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from models.agem import project
fro... | 2,558 | 36.632353 | 107 | py |
mammoth | mammoth-master/models/lwf.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from datasets import get_dataset
from torch.optim ... | 4,018 | 40.864583 | 120 | py |
mammoth | mammoth-master/models/ewc_on.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.nn.functional as F
... | 2,878 | 34.109756 | 107 | py |
mammoth | mammoth-master/models/er_ace.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from datasets import get_dataset
from models.util... | 2,345 | 32.042254 | 112 | py |
mammoth | mammoth-master/models/xder.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
# from utils.spkdloss import SPKDLoss
from dataset... | 13,072 | 46.194946 | 164 | py |
mammoth | mammoth-master/models/agem.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from models.gem import overwri... | 2,820 | 35.166667 | 112 | py |
mammoth | mammoth-master/models/rpc.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from datasets import get_dataset
from models.util... | 4,542 | 32.160584 | 112 | py |
mammoth | mammoth-master/models/lucir.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
from copy import deepcopy
import numpy as np
impor... | 12,540 | 38.686709 | 152 | py |
mammoth | mammoth-master/models/xder_ce.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
# from utils.spkdloss import SPKDLoss
from dataset... | 11,181 | 43.907631 | 150 | py |
mammoth | mammoth-master/models/fdr.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from models.utils.continual_model import ContinualMode... | 3,470 | 39.360465 | 112 | py |
mammoth | mammoth-master/models/der.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from torch.nn import functional as F
from models.utils.continual_mo... | 1,790 | 34.82 | 107 | py |
mammoth | mammoth-master/models/joint.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import numpy as np
import torch
from datasets.util... | 4,472 | 38.584071 | 112 | py |
mammoth | mammoth-master/models/xder_rpc.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from datasets import get_datase... | 11,996 | 41.242958 | 154 | py |
mammoth | mammoth-master/models/pnn.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
import torch.optim as optim
from ... | 3,027 | 31.913043 | 107 | py |
mammoth | mammoth-master/models/derpp.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from torch.nn import functional as F
from models.utils.continual_mo... | 2,234 | 36.25 | 107 | py |
mammoth | mammoth-master/models/gdumb.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from torch.optim import SGD, lr_scheduler
from models.utils.co... | 3,893 | 41.791209 | 160 | py |
mammoth | mammoth-master/models/joint_gcl.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import torch
from torch.optim import SGD
from models.u... | 2,272 | 35.079365 | 107 | py |
mammoth | mammoth-master/models/lwf_mc.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from copy import deepcopy
import torch
import torch.nn.functional as... | 2,991 | 33 | 107 | py |
mammoth | mammoth-master/models/si.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from models.utils.continual_mode... | 2,448 | 35.552239 | 113 | py |
mammoth | mammoth-master/models/er.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
from models.utils.continual_model import ContinualMode... | 1,716 | 33.34 | 107 | py |
mammoth | mammoth-master/models/bic.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import sys
from copy import deepcopy
import torch
import torch... | 7,977 | 38.300493 | 140 | py |
mammoth | mammoth-master/models/icarl.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from copy import deepcopy
import torch
import torch.nn.functio... | 8,015 | 34.312775 | 112 | py |
mammoth | mammoth-master/models/utils/continual_model.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import sys
from argparse import Namespace
from contextlib import sup... | 2,725 | 33.075 | 107 | py |
mammoth | mammoth-master/datasets/mnist_360.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from argparse import Namespace
from copy import deepcopy
from t... | 8,683 | 39.018433 | 112 | py |
mammoth | mammoth-master/datasets/perm_mnist.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from typing import Tuple, Type
import torch.nn.functional as F... | 3,661 | 30.843478 | 112 | py |
mammoth | mammoth-master/datasets/seq_tinyimagenet.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import os
from typing import Optional
import numpy as np
impor... | 6,533 | 33.571429 | 148 | py |
mammoth | mammoth-master/datasets/seq_cifar10.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from typing import Tuple
import torch.nn.functional as F
impor... | 4,753 | 33.955882 | 119 | py |
mammoth | mammoth-master/datasets/seq_mnist.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from typing import Tuple
import torch.nn.functional as F
impor... | 3,496 | 30.790909 | 112 | py |
mammoth | mammoth-master/datasets/seq_cifar100.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from typing import Tuple
import torch.nn.functional as F
impor... | 5,250 | 34.721088 | 124 | py |
mammoth | mammoth-master/datasets/rot_mnist.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch.nn.functional as F
import torchvision.transforms a... | 1,514 | 25.578947 | 112 | py |
mammoth | mammoth-master/datasets/utils/continual_dataset.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from argparse import Namespace
from typing import Tuple
import... | 5,134 | 33.695946 | 112 | py |
mammoth | mammoth-master/datasets/utils/validation.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import os
from typing import Optional
import numpy as np
import tor... | 2,804 | 34.0625 | 107 | py |
mammoth | mammoth-master/datasets/transforms/rotation.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torchvision.transforms.functional as F
c... | 2,854 | 29.698925 | 107 | py |
mammoth | mammoth-master/utils/batch_norm.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
class bn_track_stats:
d... | 912 | 37.041667 | 112 | py |
mammoth | mammoth-master/utils/continual_training.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from argparse import Namespace
import torch
from datasets imp... | 2,781 | 30.258427 | 112 | py |
mammoth | mammoth-master/utils/main.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy # needed (don't change it)
import importlib
impor... | 4,849 | 33.892086 | 124 | py |
mammoth | mammoth-master/utils/simclrloss.py | """
Author: Yonglong Tian (yonglong@mit.edu)
Date: May 07, 2020
Source: https://github.com/HobbitLong/SupContrast/blob/master/losses.py
"""
import torch
import torch.nn as nn
class SupConLoss(nn.Module):
"""Supervised Contrastive Learning: https://arxiv.org/pdf/2004.11362.pdf.
It also supports the unsupervis... | 3,808 | 38.268041 | 80 | py |
mammoth | mammoth-master/utils/augmentations.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
import torch.nn.functional as F... | 3,858 | 30.892562 | 161 | py |
mammoth | mammoth-master/utils/training.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import math
import sys
from argparse import Namespace
from typi... | 7,158 | 37.283422 | 112 | py |
mammoth | mammoth-master/utils/buffer.py | # Copyright 2022-present, Lorenzo Bonicelli, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from copy import deepcopy
from typing import Tuple
import nump... | 9,221 | 39.447368 | 119 | py |
mammoth | mammoth-master/utils/ring_buffer.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from typing import Tuple
import numpy as np
import torch
from torch... | 5,025 | 37.96124 | 107 | py |
mammoth | mammoth-master/utils/distributed.py | import os
import sys
import torch
import torch.distributed as dist
from torch.nn.parallel import DataParallel
from torch.nn.parallel import DistributedDataParallel as DDP
def setup(rank, world_size):
host = os.environ['SLURM_NODELIST'].split(',')[0]
ephemeral_port_range = 65535 - 32768
port = 32768 + int... | 2,704 | 31.987805 | 132 | py |
mammoth | mammoth-master/utils/conf.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import random
import torch
import numpy as np
def get_device() -> t... | 1,273 | 24.48 | 107 | py |
mammoth | mammoth-master/utils/gss_buffer.py | # Copyright 2020-present, Pietro Buzzega, Matteo Boschini, Angelo Porrello, Davide Abati, Simone Calderara.
# All rights reserved.
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from typing import Tuple
import numpy as np
import torch
import tor... | 7,434 | 38.759358 | 151 | py |
AdversariallyRobustTraining | AdversariallyRobustTraining-master/drawHistogramNew.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
import torch
import argparse
import os
from tqdm import trange
import numpy as np
from DataHandler import DataHandler
from Logging import info, success, warn
import numpy as np
import matplotlib.pyplot as plt
import pdb
# -------------------------------------... | 6,964 | 43.363057 | 182 | py |
AdversariallyRobustTraining | AdversariallyRobustTraining-master/main.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Main file used to train models.
import math
import os
import torch
import argparse
import json
import numpy as np
import re
import torch.nn as nn
from tqdm import trange
from Optimizers import Optimizers
from NoiseGenerator import NeighborGenerator, UnlabeledGenerator... | 24,800 | 49.821721 | 272 | py |
AdversariallyRobustTraining | AdversariallyRobustTraining-master/NoiseGenerator.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Utility file serving as the noise generator for unlabeled data and neighbor data.
import torch
class NoiseGenerator:
"""
Add Gaussian noise to anchors point (labeled/unlabeled)
to make neighbor points
"""
def __init__(self, std, num_noise_per_ancho... | 3,957 | 29.682171 | 148 | py |
AdversariallyRobustTraining | AdversariallyRobustTraining-master/getSoftmaxHistogram.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 9 11:18 2020
@author: cheonglc
"""
import math
import os
import torch
import torchvision
import argparse
import numpy as np
import pdb
import matplotlib.pyplot as plt
from DataHandler import DataHandler
from tqdm import trange
from PIL import Image... | 15,105 | 48.205212 | 170 | py |
AdversariallyRobustTraining | AdversariallyRobustTraining-master/FGSM.py | import numpy as np
import torch
from copy import deepcopy
def fgsm(image, labels, model, epsilon, device, num_classes=10):
is_cuda = device == 'cuda' and torch.cuda.is_available()
if is_cuda:
image = image.cuda()
model = model.cuda()
image_copy = deepcopy(image)
image = torch.as_tensor... | 1,399 | 40.176471 | 170 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.