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 |
|---|---|---|---|---|---|---|
modern-srwm | modern-srwm-main/reinforcement_learning/tests/polybeast_learn_function_test.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 7,901 | 39.111675 | 85 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/tests/core_agent_state_test.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 4,910 | 33.584507 | 88 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/tests/polybeast_inference_test.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 5,191 | 39.248062 | 89 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/layer.py | import math
import torch
from torch import nn
from torch.nn import functional as F
from torchbeast.fast_weight import fast_weight_delta
from torchbeast.fast_transformers import fast_weight_sum
from torchbeast.rec_update_fwm_tanh import rec_update_fwm_tanh
from torchbeast.fast_weight_rnn_v2 import fast_rnn_v2
from tor... | 42,905 | 33.573731 | 85 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/atari_wrappers.py | # The MIT License
#
# Copyright (c) 2017 OpenAI (http://openai.com)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, co... | 11,424 | 32.902077 | 130 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/polybeast.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 1,674 | 26.916667 | 83 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/noneg_polybeast_learner.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 35,307 | 37.088457 | 130 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/polybeast_env.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 2,801 | 29.791209 | 86 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/model.py | import nest
import torch
from torch import nn
from torch.nn import functional as F
from torchbeast.layer import DeltaNetLayer
from torchbeast.layer import LinearTransformerLayer
from torchbeast.layer import FastFFRecUpdateTanhLayer
from torchbeast.layer import FastRNNModelLayer
from torchbeast.layer import DeltaDelta... | 32,836 | 33.895855 | 86 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/polybeast_learner.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 31,262 | 37.596296 | 130 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/core/vtrace.py | # This file taken from
# https://github.com/deepmind/scalable_agent/blob/
# cd66d00914d56c8ba2f0615d9cdeefcb169a8d70/vtrace.py
# and modified.
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#... | 4,350 | 30.078571 | 86 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/core/environment.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 2,470 | 32.849315 | 75 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/self_ref_v0/__init__.py | # Adaptation of the original code from
# https://github.com/idiap/fast-transformers/blob/master/fast_transformers/causal_product/__init__.py
# Copyright (c) 2020 Idiap Research Institute, http://www.idiap.ch/
# Written by Angelos Katharopoulos <angelos.katharopoulos@idiap.ch>,
# Apoorv Vyas <avyas@idiap.ch>
# Modificat... | 14,184 | 33.85258 | 113 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/rec_update_fwm_tanh/__init__.py | # Adaptation of the original code from
# https://github.com/idiap/fast-transformers/blob/master/fast_transformers/causal_product/__init__.py
# Copyright (c) 2020 Idiap Research Institute, http://www.idiap.ch/
# Written by Angelos Katharopoulos <angelos.katharopoulos@idiap.ch>,
# Apoorv Vyas <avyas@idiap.ch>
# Modificat... | 13,684 | 32.055556 | 113 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/fast_weight/__init__.py | # Adaptation of the original code from
# https://github.com/idiap/fast-transformers/blob/master/fast_transformers/causal_product/__init__.py
# Copyright (c) 2020 Idiap Research Institute, http://www.idiap.ch/
# Written by Angelos Katharopoulos <angelos.katharopoulos@idiap.ch>,
# Apoorv Vyas <avyas@idiap.ch>
# Modificat... | 8,278 | 30.720307 | 113 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/fast_transformers/__init__.py | # Copyright (c) 2020 Idiap Research Institute, http://www.idiap.ch/
# Written by Angelos Katharopoulos <angelos.katharopoulos@idiap.ch>,
# Apoorv Vyas <avyas@idiap.ch>
# https://github.com/idiap/fast-transformers/blob/master/fast_transformers/causal_product/__init__.py
# Modifications Copyright (c) 2021 Kazuki Irie
im... | 6,218 | 28.473934 | 113 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/fast_weight_rnn_v2/__init__.py | # Adaptation of the original code from
# https://github.com/idiap/fast-transformers/blob/master/fast_transformers/causal_product/__init__.py
# Copyright (c) 2020 Idiap Research Institute, http://www.idiap.ch/
# Written by Angelos Katharopoulos <angelos.katharopoulos@idiap.ch>,
# Apoorv Vyas <avyas@idiap.ch>
#
# Modific... | 9,336 | 31.533101 | 113 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast/self_ref_v1/__init__.py | # Adaptation of the original code from
# https://github.com/idiap/fast-transformers/blob/master/fast_transformers/causal_product/__init__.py
# Copyright (c) 2020 Idiap Research Institute, http://www.idiap.ch/
# Written by Angelos Katharopoulos <angelos.katharopoulos@idiap.ch>,
# Apoorv Vyas <avyas@idiap.ch>
# Modificat... | 14,018 | 34.223618 | 113 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast_procgen/procgen_wrappers.py | # The MIT License
#
# Copyright (c) 2017 OpenAI (http://openai.com)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, co... | 11,994 | 31.953297 | 130 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast_procgen/polybeast.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 1,714 | 27.114754 | 83 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast_procgen/polybeast_env.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 5,260 | 28.723164 | 83 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast_procgen/model.py | import nest
import torch
from torch import nn
from torch.nn import functional as F
from torchbeast.layer import DeltaNetLayer
from torchbeast.layer import LinearTransformerLayer
from torchbeast.layer import FastFFRecUpdateTanhLayer
from torchbeast.layer import FastRNNModelLayer
from torchbeast.layer import DeltaDelta... | 57,563 | 33.510791 | 111 | py |
modern-srwm | modern-srwm-main/reinforcement_learning/torchbeast_procgen/polybeast_learner.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# 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 ... | 51,532 | 39.705371 | 136 | py |
modern-srwm | modern-srwm-main/supervised_learning/eval_delay_multi_sequential.py | # main file to be executed to evaluate models in sequential multi-task few shot
# learning
import os
import sys
import json
import time
from datetime import datetime
import argparse
import logging
import numpy as np
import random
import torch
from torchmeta_local.utils.data import BatchMetaDataLoader
from torchmeta_l... | 13,569 | 40.371951 | 83 | py |
modern-srwm | modern-srwm-main/supervised_learning/layer.py | # Contain basic layers
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from fast_weight import fast_weight_delta
from self_ref_v0 import self_ref_v0, stateful_self_ref_v0
@torch.jit.script
def elu_p1(x):
return F.elu(x, 1., False) + 1.
@torch.jit.script
def sum_norm(x):
retu... | 6,957 | 31.976303 | 98 | py |
modern-srwm | modern-srwm-main/supervised_learning/main_few_shot_sync.py | # Main file to be executed to train models for few shot learning in the
# synchrous-label setting
import os
import sys
import json
import time
from datetime import datetime
import argparse
import logging
import numpy as np
import random
import torch
import torch.nn as nn
from warmup_lr import WarmupWrapper
from torch... | 25,438 | 39.7024 | 79 | py |
modern-srwm | modern-srwm-main/supervised_learning/utils_few_shot.py | # Implement evaluation functions
import torch
# eval function for sync-label case
def eval_model_label_sync(model, eval_dataloader, num_steps, device='cuda'):
val_running_correct = 0
val_running_total = 0
for val_batch_id, val_batch in enumerate(eval_dataloader):
val_inputs, val_targets = val_ba... | 12,900 | 37.510448 | 89 | py |
modern-srwm | modern-srwm-main/supervised_learning/resnet_impl.py | # File copied from https://github.com/yinboc/few-shot-meta-baseline/blob/master/models/resnet12.py
# Used with minor modifications.
# =============================================================================
# MIT License
#
# Copyright (c) 2020 Yinbo Chen
#
# Permission is hereby granted, free of charge, to any per... | 8,026 | 26.968641 | 98 | py |
modern-srwm | modern-srwm-main/supervised_learning/eval_sync.py | # main file to be executed to evaluate models for few shot learning in the
# synchrous-label setting
import os
import sys
import json
import time
from datetime import datetime
import argparse
import logging
import numpy as np
import random
import torch
from torchmeta_local.utils.data import BatchMetaDataLoader
from ... | 14,554 | 40.467236 | 80 | py |
modern-srwm | modern-srwm-main/supervised_learning/main_few_shot_delayed_multi_sequential.py | # main file to be executed to train models in sequential multi-task few shot
# learning
import os
import sys
import json
import time
from datetime import datetime
import argparse
import logging
import numpy as np
import random
import torch
import torch.nn as nn
from torchmeta_local.utils.data import BatchMetaDataLoad... | 27,474 | 38.194009 | 96 | py |
modern-srwm | modern-srwm-main/supervised_learning/model_few_shot.py | # Implement models for few shot image classification
# NB: the current implementation uses one-hot encoding for label feedback
# (it might make sense to replace it by a regular embedding layer)
import torch
import torch.nn as nn
from layer import FastFFlayer, TransformerFFlayers, SRWMlayer
from resnet_impl import resn... | 20,639 | 34.895652 | 79 | py |
modern-srwm | modern-srwm-main/supervised_learning/main_few_shot_sync_bootstrapping.py | # Main file to be executed to train models for few shot learning in the
# synchrous-label setting
import os
import sys
import json
import time
import hashlib
from datetime import datetime
import argparse
import logging
import numpy as np
import random
import torch
import torch.nn as nn
import torch.nn.functional as F... | 32,042 | 40.028169 | 103 | py |
modern-srwm | modern-srwm-main/supervised_learning/self_ref_v0/__init__.py | # Adaptation of the original code from
# https://github.com/idiap/fast-transformers/blob/master/fast_transformers/causal_product/__init__.py
# Copyright (c) 2020 Idiap Research Institute, http://www.idiap.ch/
# Written by Angelos Katharopoulos <angelos.katharopoulos@idiap.ch>,
# Apoorv Vyas <avyas@idiap.ch>
# Modificat... | 16,123 | 32.945263 | 113 | py |
modern-srwm | modern-srwm-main/supervised_learning/fast_weight/__init__.py | # Adaptation of the original code from
# https://github.com/idiap/fast-transformers/blob/master/fast_transformers/causal_product/__init__.py
# Copyright (c) 2020 Idiap Research Institute, http://www.idiap.ch/
# Written by Angelos Katharopoulos <angelos.katharopoulos@idiap.ch>,
# Apoorv Vyas <avyas@idiap.ch>
# Modificat... | 8,121 | 30.48062 | 113 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/__init__.py | from torchmeta_local import datasets
# from torchmeta_local import modules
# from torchmeta_local import toy
from torchmeta_local import transforms
from torchmeta_local import utils
# from torchmeta_local.version import VERSION as __version__
| 244 | 29.625 | 60 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/omniglot.py | import os
import json
import glob
import h5py
from PIL import Image, ImageOps
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
from torchvision.datasets.utils import list_dir, download_url
from torchmeta_local.datasets.utils import get_asset
class Omniglot(CombinationMetaDataset):... | 10,994 | 40.334586 | 92 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/miniimagenet.py | import os
import pickle
from PIL import Image
import h5py
import json
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
# QKFIX: See torchmeta_local.datasets.utils for more informations
from torchmeta_local.datasets.utils import download_file_from_google_drive
class MiniImagenet(Co... | 8,994 | 38.279476 | 92 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/triplemnist.py | import numpy as np
from PIL import Image
import os
import io
import json
import glob
import h5py
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
# QKFIX: See torchmeta_local.datasets.utils for more informations
from torchmeta_local.datasets.utils import download_file_from_google_dr... | 10,053 | 38.582677 | 85 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/cub.py | import numpy as np
from PIL import Image
import os
import io
import json
import glob
import h5py
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
# QKFIX: See torchmeta_local.datasets.utils for more informations
from torchmeta_local.datasets.utils import download_file_from_google_dr... | 9,765 | 38.861224 | 103 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/pascal5i.py | """
;==========================================
; Title: Pascal-5i Dataset for Few-shot Object Segmentation
; Author: Mennatullah Siam
; Company: Huawei Technologies
; Date: 18 March 2020
;==========================================
"""
import os
import json
import glob
import h5py
from PIL import Image, ImageOps
fro... | 9,715 | 35.80303 | 116 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/letter.py | import numpy as np
import os
import json
import h5py
from tqdm import tqdm
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
from torchmeta_local.datasets.utils import get_asset
class Letter(CombinationMetaDataset):
"""The Letter Image Recognition Dataset """
def __init__(s... | 11,355 | 41.691729 | 121 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/tieredimagenet.py | import numpy as np
from PIL import Image
import h5py
import json
import os
import io
import pickle
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
# QKFIX: See torchmeta_local.datasets.utils for more informations
from torchmeta_local.datasets.utils import download_file_from_google_... | 10,425 | 40.373016 | 93 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/tcga.py | import os
import json
import h5py
import numpy as np
import torch
import copy
from ordered_set import OrderedSet
from torchmeta_local.utils.data import Task, MetaDataset
from torchmeta_local.datasets.utils import get_asset
class TCGA(MetaDataset):
"""
The TCGA dataset [1]. A dataset of classification tasks o... | 21,312 | 39.289225 | 104 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/utils.py | import os
import json
def get_asset_path(*args):
basedir = os.path.dirname(__file__)
return os.path.join(basedir, 'assets', *args)
def get_asset(*args, dtype=None):
filename = get_asset_path(*args)
if not os.path.isfile(filename):
raise IOError('{} not found'.format(filename))
if dtype ... | 3,330 | 36.852273 | 111 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/helpers_tabular.py | import warnings
from torchmeta_local.datasets import Letter, PlantsTexture, PlantsShape, PlantsMargin, Bach
from torchmeta_local.transforms import Categorical, ClassSplitter
from torchmeta_local.transforms.tabular_transforms import NumpyToTorch
__all__ = [
'letter',
'plants_texture',
'plants_shape',
'... | 6,290 | 34.744318 | 101 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/bach.py | import numpy as np
import os
import json
import h5py
from tqdm import tqdm
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
from torchmeta_local.datasets.utils import get_asset
class Bach(CombinationMetaDataset):
"""The Bach dataset """
def __init__(self, root, num_classes... | 18,777 | 43.709524 | 118 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/one_hundred_plants_shape.py | import numpy as np
import os
import json
import h5py
from tqdm import tqdm
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
from torchmeta_local.datasets.utils import get_asset
class PlantsShape(CombinationMetaDataset):
"""The PlantsShape dataset """
def __init__(self, roo... | 14,340 | 43.676012 | 121 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/doublemnist.py | import numpy as np
from PIL import Image
import os
import io
import json
import glob
import h5py
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
# QKFIX: See torchmeta_local.datasets.utils for more informations
from torchmeta_local.datasets.utils import download_file_from_google_dr... | 10,042 | 38.53937 | 85 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/__init__.py | from torchmeta_local.datasets.triplemnist import TripleMNIST
from torchmeta_local.datasets.doublemnist import DoubleMNIST
from torchmeta_local.datasets.cub import CUB
from torchmeta_local.datasets.cifar100 import CIFARFS, FC100
from torchmeta_local.datasets.miniimagenet import MiniImagenet
from torchmeta_local.datasets... | 1,277 | 30.95 | 77 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/one_hundred_plants_texture.py | import numpy as np
import os
import json
import h5py
from tqdm import tqdm
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
from torchmeta_local.datasets.utils import get_asset
class PlantsTexture(CombinationMetaDataset):
"""The PlantsTexture dataset """
def __init__(self,... | 14,441 | 44.13125 | 123 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/one_hundred_plants_margin.py | import numpy as np
import os
import json
import h5py
from tqdm import tqdm
from torchmeta_local.utils.data import Dataset, ClassDataset, CombinationMetaDataset
from torchmeta_local.datasets.utils import get_asset
class PlantsMargin(CombinationMetaDataset):
"""The PlantsMargin dataset """
def __init__(self, r... | 14,418 | 44.059375 | 122 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/helpers.py | import warnings
from torchmeta_local.datasets import (
Omniglot, MiniImagenet, TieredImagenet, CIFARFS, FC100, CUB, DoubleMNIST,
TripleMNIST, Pascal5i)
from torchmeta_local.transforms import (
Categorical, ClassSplitter, Rotation, SegmentationPairTransform)
from torchvision.transforms import (
Compose,... | 22,150 | 31.962798 | 110 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/cifar100/base.py | import numpy as np
import os
import json
import h5py
from PIL import Image
from torchvision.datasets.utils import check_integrity, download_url
from torchmeta_local.utils.data import Dataset, ClassDataset
class CIFAR100ClassDataset(ClassDataset):
folder = 'cifar100'
subfolder = None
download_url = 'https... | 6,667 | 36.886364 | 91 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/cifar100/cifar_fs.py | import os
import json
from torchmeta_local.datasets.cifar100.base import CIFAR100ClassDataset
from torchmeta_local.datasets.utils import get_asset
from torchmeta_local.utils.data import ClassDataset, CombinationMetaDataset
class CIFARFS(CombinationMetaDataset):
"""
The CIFAR-FS dataset, introduced in [1]. Th... | 5,157 | 42.344538 | 85 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/cifar100/__init__.py | from torchmeta_local.datasets.cifar100.cifar_fs import CIFARFS
from torchmeta_local.datasets.cifar100.fc100 import FC100
__all__ = ['CIFARFS', 'FC100']
| 153 | 29.8 | 62 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/datasets/cifar100/fc100.py | import os
import json
from torchmeta_local.datasets.cifar100.base import CIFAR100ClassDataset
from torchmeta_local.datasets.utils import get_asset
from torchmeta_local.utils.data import ClassDataset, CombinationMetaDataset
class FC100(CombinationMetaDataset):
"""
The Fewshot-CIFAR100 dataset, introduced in [... | 5,526 | 42.865079 | 85 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/utils/__init__.py | from torchmeta_local.utils import data
# from torchmeta_local.utils.gradient_based import gradient_update_parameters
# from torchmeta_local.utils.metrics import hardness_metric
# from torchmeta_local.utils.prototype import get_num_samples, get_prototypes, prototypical_loss
# from torchmeta_local.utils.matching import p... | 749 | 34.714286 | 124 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/utils/data/sampler.py | import random
import warnings
from itertools import combinations
from torch.utils.data.sampler import SequentialSampler, RandomSampler
from torchmeta_local.utils.data.dataset import CombinationMetaDataset
__all__ = ['CombinationSequentialSampler', 'CombinationRandomSampler']
class CombinationSequentialSampler(Seque... | 2,094 | 45.555556 | 80 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/utils/data/task.py | import random
from torch.utils.data import ConcatDataset, Subset
from torch.utils.data import Dataset as Dataset_
from torchvision.transforms import Compose
__all__ = ['Dataset', 'Task', 'ConcatTask', 'SubsetTask']
class Dataset(Dataset_):
def __init__(self, index, transform=None, target_transform=None):
... | 2,352 | 32.140845 | 79 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/utils/data/dataloader.py | from collections import OrderedDict
from torch.utils.data import DataLoader
from torch.utils.data.dataloader import default_collate
from torch.utils.data.dataset import Dataset as TorchDataset
from torchmeta_local.utils.data.dataset import CombinationMetaDataset
from torchmeta_local.utils.data.sampler import (Combina... | 2,613 | 39.84375 | 88 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/utils/data/dataset.py | import sys
import numpy as np
import warnings
from copy import deepcopy
from itertools import combinations
from ordered_set import OrderedSet
from torchvision.transforms import Compose
from torchmeta_local.utils.data.task import ConcatTask
from torchmeta_local.transforms import FixedCategory, Categorical, DefaultTar... | 13,749 | 41.701863 | 89 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/utils/data/wrappers.py | import numpy as np
import io
from PIL import Image
from torch.utils.data import Dataset
from torchmeta_local.utils.data.dataset import CombinationMetaDataset
class NonEpisodicWrapper(Dataset):
"""Non-episodic wrapper to convert a CombinationMetaDataset into a standard
PyTorch Dataset, compatible with (non-e... | 3,110 | 36.481928 | 85 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/utils/data/__init__.py | from torchmeta_local.utils.data.dataloader import MetaDataLoader, BatchMetaDataLoader
from torchmeta_local.utils.data.dataset import ClassDataset, MetaDataset, CombinationMetaDataset
from torchmeta_local.utils.data.sampler import CombinationSequentialSampler, CombinationRandomSampler
from torchmeta_local.utils.data.tas... | 723 | 33.47619 | 101 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/transforms/augmentations.py | import torchvision.transforms.functional as F
class Rotation(object):
def __init__(self, angle, resample=False, expand=False, center=None):
super(Rotation, self).__init__()
if isinstance(angle, (list, tuple)):
self._angles = angle
self.angle = None
else:
... | 2,589 | 33.078947 | 84 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/transforms/utils.py | from torchvision.transforms import Compose
from torchmeta_local.utils.data.task import Task
def apply_wrapper(wrapper, task_or_dataset=None):
if task_or_dataset is None:
return wrapper
from torchmeta_local.utils.data import MetaDataset
if isinstance(task_or_dataset, Task):
return wrapper(t... | 1,101 | 35.733333 | 73 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/transforms/target_transforms.py | from torchvision.transforms import Compose, Resize, ToTensor
import PIL
class SegmentationPairTransform(object):
def __init__(self, target_size):
self.image_transform = Compose([Resize((target_size, target_size)), ToTensor()])
self.mask_transform = Compose([Resize((target_size, target_size),
... | 1,325 | 34.837838 | 88 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/transforms/categorical.py | import torch
from torchmeta_local.transforms.utils import apply_wrapper
from collections import defaultdict
from torchmeta_local.transforms.target_transforms import TargetTransform
class Categorical(TargetTransform):
"""Target transform to return labels in `[0, num_classes)`.
Parameters
----------
n... | 2,710 | 33.316456 | 86 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/transforms/splitters.py | import torch
import numpy as np
from collections import OrderedDict, defaultdict
from torchmeta_local.utils.data.task import Task, ConcatTask, SubsetTask
from torchmeta_local.transforms.utils import apply_wrapper
__all__ = ['Splitter', 'ClassSplitter', 'WeightedClassSplitter']
class Splitter(object):
def __init... | 16,290 | 43.149051 | 88 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/transforms/__init__.py | from torchmeta_local.transforms.categorical import Categorical, FixedCategory
from torchmeta_local.transforms.augmentations import Rotation, HorizontalFlip, VerticalFlip
from torchmeta_local.transforms.splitters import Splitter, ClassSplitter, WeightedClassSplitter
from torchmeta_local.transforms.target_transforms impo... | 461 | 76 | 123 | py |
modern-srwm | modern-srwm-main/supervised_learning/torchmeta_local/transforms/tabular_transforms.py | import torch
import numpy as np
class NumpyToTorch:
"""Convert a numpy.ndarray to a pytorch.tensor."""
def __call__(self, numpy_array: np.ndarray) -> torch.tensor:
"""
Parameters
----------
numpy_array : np.ndarray
the numpy array
Returns
-------
... | 555 | 22.166667 | 73 | py |
auto-attack | auto-attack-master/autoattack/utils_tf.py | import tensorflow as tf
import numpy as np
import torch
class ModelAdapter():
def __init__(self, logits, x, y, sess, num_classes=10):
self.logits = logits
self.sess = sess
self.x_input = x
self.y_input = y
self.num_classes = num_classes
# gradients of logits... | 4,883 | 45.514286 | 171 | py |
auto-attack | auto-attack-master/autoattack/autoattack.py | import math
import time
import numpy as np
import torch
from .other_utils import Logger
from autoattack import checks
from autoattack.state import EvaluationState
class AutoAttack():
def __init__(self, model, norm='Linf', eps=.3, seed=None, verbose=True,
attacks_to_run=[], version='standard', i... | 16,294 | 47.067847 | 121 | py |
auto-attack | auto-attack-master/autoattack/checks.py | import torch
import warnings
import math
import sys
from autoattack.other_utils import L2_norm
funcs = {'grad': 0,
'backward': 0,
#'enable_grad': 0
'_make_grads': 0,
}
checks_doc_path = 'flags_doc.md'
def check_randomized(model, x, y, bs=250, n=5, alpha=1e-4, logger=None):
acc = []
corrcl ... | 5,206 | 35.412587 | 95 | py |
auto-attack | auto-attack-master/autoattack/state.py | import json
from dataclasses import dataclass, field, asdict
from datetime import datetime
from pathlib import Path
from typing import Optional, Set
import warnings
import torch
@dataclass
class EvaluationState:
_attacks_to_run: Set[str]
path: Optional[Path] = None
_run_attacks: Set[str] = field(default_... | 3,056 | 32.966667 | 87 | py |
auto-attack | auto-attack-master/autoattack/other_utils.py | import os
import collections.abc as container_abcs
import torch
class Logger():
def __init__(self, log_path):
self.log_path = log_path
def log(self, str_to_log):
print(str_to_log)
if not self.log_path is None:
with open(self.log_path, 'a') as f:
f.w... | 1,577 | 25.745763 | 102 | py |
auto-attack | auto-attack-master/autoattack/fab_base.py | # Copyright (c) 2019-present, Francesco Croce
# 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 __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ i... | 14,703 | 43.557576 | 140 | py |
auto-attack | auto-attack-master/autoattack/square.py | # Copyright (c) 2020-present, Francesco Croce
# 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 __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ i... | 26,018 | 41.033926 | 99 | py |
auto-attack | auto-attack-master/autoattack/autopgd_base.py | # Copyright (c) 2020-present, Francesco Croce
# 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 time
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import random
from autoattack.other... | 26,198 | 37.079942 | 99 | py |
auto-attack | auto-attack-master/autoattack/utils_tf2.py | import tensorflow as tf
import numpy as np
import torch
class ModelAdapter():
def __init__(self, model, num_classes=10):
"""
Please note that model should be tf.keras model without activation function 'softmax'
"""
self.num_classes = num_classes
self.tf_model = model
... | 15,775 | 30.552 | 166 | py |
auto-attack | auto-attack-master/autoattack/fab_pt.py | # Copyright (c) 2019-present, Francesco Croce
# 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 __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ i... | 3,481 | 29.278261 | 76 | py |
auto-attack | auto-attack-master/autoattack/fab_projections.py | import math
import torch
from torch.nn import functional as F
def projection_linf(points_to_project, w_hyperplane, b_hyperplane):
device = points_to_project.device
t, w, b = points_to_project, w_hyperplane.clone(), b_hyperplane.clone()
sign = 2 * ((w * t).sum(1) - b >= 0) - 1
w.mul_(sign.unsqueeze(1... | 5,076 | 30.147239 | 98 | py |
auto-attack | auto-attack-master/autoattack/fab_tf.py | # Copyright (c) 2019-present, Francesco Croce
# 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 __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ i... | 2,599 | 28.545455 | 76 | py |
auto-attack | auto-attack-master/autoattack/examples/eval_tf1.py | #%%
from argparse import ArgumentParser
import numpy as np
import tensorflow as tf
import torch
import torch.nn as nn
import torchvision.datasets as datasets
import torch.utils.data as data
import torchvision.transforms as transforms
import sys
#sys.path.insert(0,'..')
from autoattack import AutoAttack, utils_tf
#
... | 5,460 | 35.165563 | 141 | py |
auto-attack | auto-attack-master/autoattack/examples/resnet.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicBlock(nn.Module):
expansion = 1
def __init__(self, in_planes, planes, stride=1):
super(BasicBlock, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
... | 3,828 | 32.008621 | 104 | py |
auto-attack | auto-attack-master/autoattack/examples/eval_tf2.py | #%%
from argparse import ArgumentParser
import numpy as np
import tensorflow as tf
import torch
import torch.nn as nn
import torchvision.datasets as datasets
import torch.utils.data as data
import torchvision.transforms as transforms
import sys
sys.path.insert(0, '..')
from autoattack import AutoAttack, utils_tf2
... | 5,193 | 34.575342 | 151 | py |
auto-attack | auto-attack-master/autoattack/examples/eval.py | import os
import argparse
from pathlib import Path
import warnings
import torch
import torch.nn as nn
import torchvision.datasets as datasets
import torch.utils.data as data
import torchvision.transforms as transforms
import sys
sys.path.insert(0,'..')
from resnet import *
if __name__ == '__main__':
parser = ar... | 3,071 | 36.012048 | 103 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/SphereDenoisingMNN.py | # 2022/10/20~
# Claudio Battiloro, clabat@seas.upenn.edu/claudio.battiloro@uniroma1.it
# Zhiyang Wang, zhiyangw@seas.upenn.edu
# Hans Riess
# Thanks to:
# Fernando Gama, fgama@seas.upenn.edu
# Luana Ruiz, rubruiz@seas.upenn.edu
# for implementing the "alegnn" library.
# This is the code used for implementing the MNN ... | 36,535 | 45.661558 | 177 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/SphereDenoisingDDTNN.py | # 2022/10/20~
# Claudio Battiloro, clabat@seas.upenn.edu/claudio.battiloro@uniroma1.it
# Zhiyang Wang, zhiyangw@seas.upenn.edu
# Hans Riess
# Thanks to:
# Fernando Gama, fgama@seas.upenn.edu
# Luana Ruiz, rubruiz@seas.upenn.edu
# for implementing the "alegnn" library.
# This is the code used for implementing the nume... | 38,987 | 46.430657 | 177 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/alegnnss/modules/architecturesTime.py | # 2019/12/31~
# Fernando Gama, fgama@seas.upenn.edu
# Luana Ruiz, rubruiz@seas.upenn.edu
# Kate Tolstaya, eig@seas.upenn.edu
"""
architecturesTime.py Architectures module
Definition of GNN architectures. The basic idea of these architectures is that
the data comes in the form {(S_t, x_t)} where the shift operator as w... | 36,148 | 45.167305 | 80 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/alegnnss/modules/loss.py | # 2021/03/04~
# Fernando Gama, fgama@seas.upenn.edu
# Luana Ruiz, rubruiz@seas.upenn.edu
"""
loss.py Loss functions
adaptExtraDimensionLoss: wrapper that handles extra dimensions
F1Score: loss function corresponding to 1 - F1 score
"""
import torch
import torch.nn as nn
# An arbitrary loss function handling penaltie... | 6,033 | 36.478261 | 102 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/alegnnss/modules/training.py | # 2020/02/25~
# Fernando Gama, fgama@seas.upenn.edu
# Luana Ruiz, rubruiz@seas.upenn.edu
"""
training.py Training Module
Trainer classes
Trainer: general trainer that just computes a loss over a training set and
runs an evaluation on a validation test
TrainerSingleNode: trainer class that computes a loss over the... | 76,065 | 43.903188 | 85 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/alegnnss/modules/model.py | # 2018/10/02~
# Fernando Gama, fgama@seas.upenn.edu
# Luana Ruiz, rubruiz@seas.upenn.edu
"""
model.py Model Module
Utilities useful for working on the model
Model: binds together the architecture, the loss function, the optimizer,
the trainer, and the evaluator.
"""
import os
import torch
class Model:
""... | 5,959 | 35.341463 | 80 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/alegnnss/modules/architectures.py | # 2021/03/04~
# Fernando Gama, fgama@seas.upenn.edu
# Luana Ruiz, rubruiz@seas.upenn.edu
"""
architectures.py Architectures module
Definition of GNN architectures.
SelectionGNN: implements the selection GNN architecture
LocalActivationGNN: implements the selection GNN architecture with a local
activation function... | 245,270 | 48.201805 | 88 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/alegnnss/modules/evaluation.py | # 2020/02/25~
# Fernando Gama, fgama@seas.upenn.edu
# Luana Ruiz, rubruiz@seas.upenn.edu
"""
evaluation.py Evaluation Module
Methods for evaluating the models.
evaluate: evaluate a model
evaluateSingleNode: evaluate a model that has a single node forward
evaluateFlocking: evaluate a model using the flocking cost
"""
... | 9,535 | 28.073171 | 80 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/alegnnss/utils/graphML.py | # 2021/03/04~
# Fernando Gama, fgama@seas.upenn.edu.
# Luana Ruiz, rubruiz@seas.upenn.edu.
# Kate Tolstaya, eig@seas.upenn.edu
"""
graphML.py Module for basic GSP and graph machine learning functions.
Functionals
LSIGF: Applies a linear shift-invariant graph filter
spectralGF: Applies a linear shift-invariant graph f... | 176,929 | 40.679623 | 98 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/alegnnss/utils/visualTools.py | # 2019/01/21~2018/07/12
# This function is taken almost verbatim from https://github.com/amaiasalvador
# and all credit should go to Amaia Salvador.
import os
import glob
import torchvision.utils as vutils
from operator import itemgetter
from tensorboardX import SummaryWriter
class Visualizer():
def __init__(self... | 2,521 | 37.212121 | 182 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/alegnnss/utils/miscTools.py | # 2018/10/15~
# Fernando Gama, fgama@seas.upenn.edu.
# Luana Ruiz, rubruiz@seas.upenn.edu.
"""
miscTools Miscellaneous Tools module
num2filename: change a numerical value into a string usable as a filename
saveSeed: save the random state of generators
loadSeed: load the number of random state of generators
writeVarVal... | 4,291 | 37.321429 | 80 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Repo/Tangent_Bundle_NN/alegnnss/utils/dataTools.py | # 2021/03/04~
# Fernando Gama, fgama@seas.upenn.edu
# Luana Ruiz, rubruiz@seas.upenn.edu
# Kate Tolstaya, eig@seas.upenn.edu
"""
dataTools.py Data management module
Functions:
normalizeData: normalize data along a specified axis
changeDataType: change data type of data
Classes (datasets):
FacebookEgo (class): l... | 223,644 | 46.594169 | 95 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Journal_repo/architecture.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Claudio Battiloro
"""
#import sys
import torch
import torch.nn as nn
import pytorch_lightning as pl
from layers import GNNLayer, RGNNLayer
import numpy as np
# Tangent Bundle Neural Network
class TNN(pl.LightningModule):
def __init__(self, in_features, ... | 15,535 | 35.384075 | 97 | py |
Tangent-Bundle-Neural-Networks | Tangent-Bundle-Neural-Networks-main/Journal_repo/utils.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Clabat
"""
import torch
import scipy.sparse as sp
import scipy.sparse.linalg as spl
import numpy as np
from scipy.linalg import expm
import sys
# %% Sheaf Laplacian Utils
def compute_neighbours(data,epsilon,epsilon_pca, option = 'mean_shift'):
n = data.... | 12,816 | 36.043353 | 125 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.