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 |
|---|---|---|---|---|---|---|
IDEAL | IDEAL-main/code/code/transformers/tokenization_transfo_xl.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... | 21,824 | 36.62931 | 133 | py |
IDEAL | IDEAL-main/code/code/transformers/modeling_transfo_xl_utilities.py | # coding=utf-8
# Copyright 2018 Google AI, Google Brain and Carnegie Mellon University Authors and the HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the Lice... | 13,568 | 39.747748 | 132 | py |
IDEAL | IDEAL-main/code/code/transformers/convert_pytorch_checkpoint_to_tf2.py | # coding=utf-8
# Copyright 2018 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable... | 15,143 | 63.442553 | 250 | py |
IDEAL | IDEAL-main/code/code/transformers/modeling_roberta.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | 25,603 | 53.476596 | 151 | py |
IDEAL | IDEAL-main/code/code/transformers/tokenization_utils.py | # coding=utf-8
# Copyright 2018 The Open AI Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | 49,976 | 49.532861 | 372 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_transfo_xl_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 8,700 | 38.912844 | 94 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/tokenization_transfo_xl_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 2,975 | 35.292683 | 120 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_openai_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 8,855 | 39.81106 | 124 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_roberta_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 10,512 | 41.220884 | 143 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_common_test.py | # coding=utf-8
# Copyright 2019 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | 32,429 | 43.363885 | 137 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_auto_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 4,175 | 43.425532 | 122 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_bert_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 15,294 | 46.647975 | 162 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/optimization_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 6,299 | 42.150685 | 117 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_xlnet_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 14,372 | 42.68693 | 131 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_distilbert_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 9,826 | 43.265766 | 152 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_tf_distilbert_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 9,856 | 43.201794 | 151 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_tf_transfo_xl_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 8,483 | 37.917431 | 104 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_tf_common_test.py | # coding=utf-8
# Copyright 2019 HuggingFace Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | 15,587 | 42.786517 | 140 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_xlm_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 13,845 | 41.472393 | 171 | py |
IDEAL | IDEAL-main/code/code/transformers/tests/modeling_gpt2_test.py | # coding=utf-8
# Copyright 2018 The Google AI Language Team Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ... | 10,296 | 40.353414 | 135 | py |
IDEAL | IDEAL-main/code/data/trans.py | import pandas as pd
import numpy as np
import torch
import pickle
from tqdm import tqdm_notebook as tqdm
import os
import re
import pickle
os.environ["CUDA_VISIBLE_DEVICES"] = "0,1"
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
n_gpu = torch.cuda.device_count()
print("gpu num: ", n_gpu)
# Load... | 2,989 | 31.150538 | 161 | py |
TIB_VA_MediaEval_FakeNews | TIB_VA_MediaEval_FakeNews-main/train_mlp_text.py | from torch import nn
from torch.utils.data import DataLoader, Dataset, sampler, WeightedRandomSampler
import torch
from torch.autograd import Variable
import json
import os, random, copy
import numpy as np
import torch.optim as optim
import time
from sklearn import metrics, preprocessing
import pandas as pd
from sklear... | 8,318 | 28.92446 | 94 | py |
TIB_VA_MediaEval_FakeNews | TIB_VA_MediaEval_FakeNews-main/extract_covidbert.py | import sys, os
import json, re
import pandas as pd
import numpy as np
import string
import torch
from transformers import AutoModel, AutoTokenizer
from torch.utils.data import Dataset, DataLoader, SequentialSampler
from helper_funcs import *
from preprocess_covidbert import preprocess_bert
device = torch.device('cud... | 4,488 | 36.722689 | 129 | py |
TIB_VA_MediaEval_FakeNews | TIB_VA_MediaEval_FakeNews-main/helper_funcs.py | ## Good Explanation here: https://mccormickml.com/2019/05/14/BERT-word-embeddings-tutorial/
from ekphrasis.classes.preprocessor import TextPreProcessor
from ekphrasis.classes.tokenizer import SocialTokenizer
from ekphrasis.dicts.emoticons import emoticons
from nltk.corpus import stopwords
import torch
import numpy a... | 4,346 | 34.056452 | 155 | py |
mindall-e | mindall-e-main/examples/transfer_learning_ex.py | # ------------------------------------------------------------------------------------
# minDALL-E
# Copyright (c) 2021 Kakao Brain Corp. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------------... | 7,202 | 40.635838 | 120 | py |
mindall-e | mindall-e-main/dalle/models/__init__.py | # ------------------------------------------------------------------------------------
# minDALL-E
# Copyright (c) 2021 Kakao Brain Corp. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------------... | 8,618 | 41.458128 | 122 | py |
mindall-e | mindall-e-main/dalle/models/stage2/layers.py | # ------------------------------------------------------------------------------------
# minDALL-E
# Copyright (c) 2021 Kakao Brain Corp. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------------... | 5,564 | 38.468085 | 103 | py |
mindall-e | mindall-e-main/dalle/models/stage2/transformer.py | # ------------------------------------------------------------------------------------
# minDALL-E
# Copyright (c) 2021 Kakao Brain Corp. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------------... | 10,437 | 39.773438 | 113 | py |
mindall-e | mindall-e-main/dalle/models/stage1/vqgan.py | # ------------------------------------------------------------------------------------
# Modified from VQGAN (https://github.com/CompVis/taming-transformers)
# Copyright (c) 2020 Patrick Esser and Robin Rombach and Björn Ommer. All Rights Reserved.
# ---------------------------------------------------------------------... | 3,728 | 38.670213 | 98 | py |
mindall-e | mindall-e-main/dalle/models/stage1/layers.py | # ------------------------------------------------------------------------------------
# Modified from VQGAN (https://github.com/CompVis/taming-transformers)
# Copyright (c) 2020 Patrick Esser and Robin Rombach and Björn Ommer. All Rights Reserved.
# ---------------------------------------------------------------------... | 14,067 | 36.614973 | 90 | py |
mindall-e | mindall-e-main/dalle/utils/utils.py | # ------------------------------------------------------------------------------------
# minDALL-E
# Copyright (c) 2021 Kakao Brain Corp. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------------... | 2,975 | 34.011765 | 109 | py |
mindall-e | mindall-e-main/dalle/utils/sampling.py | # ------------------------------------------------------------------------------------
# minDALL-E
# Copyright (c) 2021 Kakao Brain Corp. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
# ------------------------------------------------------------------------------------... | 5,515 | 35.052288 | 102 | py |
unsup3d | unsup3d-master/run.py | import argparse
import torch
from unsup3d import setup_runtime, Trainer, Unsup3D
## runtime arguments
parser = argparse.ArgumentParser(description='Training configurations.')
parser.add_argument('--config', default=None, type=str, help='Specify a config file path')
parser.add_argument('--gpu', default=None, type=int,... | 803 | 31.16 | 119 | py |
unsup3d | unsup3d-master/unsup3d/utils.py | import os
import sys
import glob
import yaml
import random
import numpy as np
import cv2
import torch
import zipfile
def setup_runtime(args):
"""Load configs, initialize CUDA, CuDNN and the random seeds."""
# Setup CUDA
cuda_device_id = args.gpu
if cuda_device_id is not None:
os.environ["CUDA... | 5,885 | 31.7 | 135 | py |
unsup3d | unsup3d-master/unsup3d/model.py | import os
import math
import glob
import torch
import torch.nn as nn
import torchvision
from . import networks
from . import utils
from .renderer import Renderer
EPS = 1e-7
class Unsup3D():
def __init__(self, cfgs):
self.model_name = cfgs.get('model_name', self.__class__.__name__)
self.device = ... | 25,557 | 58.714953 | 182 | py |
unsup3d | unsup3d-master/unsup3d/networks.py | import torch
import torch.nn as nn
import torchvision
EPS = 1e-7
class Encoder(nn.Module):
def __init__(self, cin, cout, nf=64, activation=nn.Tanh):
super(Encoder, self).__init__()
network = [
nn.Conv2d(cin, nf, kernel_size=4, stride=2, padding=1, bias=False), # 64x64 -> 32x32
... | 8,914 | 43.575 | 107 | py |
unsup3d | unsup3d-master/unsup3d/dataloaders.py | import os
import torchvision.transforms as tfs
import torch.utils.data
import numpy as np
from PIL import Image
def get_data_loaders(cfgs):
batch_size = cfgs.get('batch_size', 64)
num_workers = cfgs.get('num_workers', 4)
image_size = cfgs.get('image_size', 64)
crop = cfgs.get('crop', None)
run_tr... | 7,221 | 37.827957 | 168 | py |
unsup3d | unsup3d-master/unsup3d/trainer.py | import os
import glob
from datetime import datetime
import numpy as np
import torch
from . import meters
from . import utils
from .dataloaders import get_data_loaders
class Trainer():
def __init__(self, cfgs, model):
self.device = cfgs.get('device', 'cpu')
self.num_epochs = cfgs.get('num_epochs', ... | 6,750 | 42 | 127 | py |
unsup3d | unsup3d-master/unsup3d/meters.py | import os
import json
import time
import torch
import operator
from functools import reduce
import matplotlib.pyplot as plt
import collections
from .utils import xmkdir
class TotalAverage():
def __init__(self):
self.reset()
def reset(self):
self.last_value = 0.
self.mass = 0.
... | 5,467 | 30.976608 | 97 | py |
unsup3d | unsup3d-master/unsup3d/renderer/renderer.py | import torch
import math
import neural_renderer as nr
from .utils import *
EPS = 1e-7
class Renderer():
def __init__(self, cfgs):
self.device = cfgs.get('device', 'cpu')
self.image_size = cfgs.get('image_size', 64)
self.min_depth = cfgs.get('min_depth', 0.9)
self.max_depth = cfgs... | 7,891 | 42.60221 | 117 | py |
unsup3d | unsup3d-master/unsup3d/renderer/utils.py | import torch
def mm_normalize(x, min=0, max=1):
x_min = x.min()
x_max = x.max()
x_range = x_max - x_min
x_z = (x - x_min) / x_range
x_out = x_z * (max - min) + min
return x_out
def rand_range(size, min, max):
return torch.rand(size)*(max-min)+min
def rand_posneg_range(size, min, max):
... | 3,529 | 31.685185 | 112 | py |
unsup3d | unsup3d-master/demo/utils.py | import os
import numpy as np
import cv2
import torch
import torch.nn as nn
class Encoder(nn.Module):
def __init__(self, cin, cout, nf=64, activation=nn.Tanh):
super(Encoder, self).__init__()
network = [
nn.Conv2d(cin, nf, kernel_size=4, stride=2, padding=1, bias=False), # 64x64 -> 32x... | 8,568 | 45.825137 | 143 | py |
unsup3d | unsup3d-master/demo/demo.py | import argparse
import numpy as np
from PIL import Image
import torch
import torch.nn as nn
from .utils import *
EPS = 1e-7
class Demo():
def __init__(self, args):
## configs
self.device = 'cuda:0' if args.gpu else 'cpu'
self.checkpoint_path = args.checkpoint
self.detect_human_fa... | 14,079 | 47.054608 | 186 | py |
l4-pytorch | l4-pytorch-master/mnist_example.py | from __future__ import print_function
import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
from torch.autograd import Variable
from l4 import L4
# Training settings
parser = argparse.ArgumentParser(description='PyTor... | 4,660 | 37.204918 | 93 | py |
l4-pytorch | l4-pytorch-master/l4.py | import torch
import torch.optim as optim
import math
class L4():
"""Implements L4: Practical loss-based stepsize adaptation for deep learning
Proposed by Michal Rolinek & Georg Martius in
`paper <https://arxiv.org/abs/1802.05074>`_.
Arguments:
params (iterable): iterable of parameters to optimize or d... | 3,016 | 26.935185 | 108 | py |
RE-ParameterizedExplainerForGraphNeuralNetworks | RE-ParameterizedExplainerForGraphNeuralNetworks-main/ExplanationEvaluation/models/GNN_paper.py | import torch
from torch.nn import ReLU, Linear
from torch_geometric.nn import GCNConv, global_max_pool, global_mean_pool
class NodeGCN(torch.nn.Module):
"""
A graph clasification model for nodes decribed in https://arxiv.org/abs/1903.03894.
This model consists of 3 stacked GCN layers followed by a linear ... | 3,648 | 34.77451 | 97 | py |
RE-ParameterizedExplainerForGraphNeuralNetworks | RE-ParameterizedExplainerForGraphNeuralNetworks-main/ExplanationEvaluation/models/model_selector.py | import torch
import os
from ExplanationEvaluation.models.GNN_paper import NodeGCN as GNN_NodeGCN
from ExplanationEvaluation.models.GNN_paper import GraphGCN as GNN_GraphGCN
from ExplanationEvaluation.models.PG_paper import NodeGCN as PG_NodeGCN
from ExplanationEvaluation.models.PG_paper import GraphGCN as PG_GraphGCN
... | 3,284 | 40.582278 | 158 | py |
RE-ParameterizedExplainerForGraphNeuralNetworks | RE-ParameterizedExplainerForGraphNeuralNetworks-main/ExplanationEvaluation/models/PG_paper.py | import torch
from torch.nn import ReLU, Linear
from torch_geometric.nn import GCNConv, BatchNorm
from torch_geometric.nn import global_mean_pool, global_max_pool
class NodeGCN(torch.nn.Module):
"""
A graph clasification model for nodes decribed in https://arxiv.org/abs/2011.04573.
This model consists of 3... | 3,529 | 34.656566 | 97 | py |
RE-ParameterizedExplainerForGraphNeuralNetworks | RE-ParameterizedExplainerForGraphNeuralNetworks-main/ExplanationEvaluation/explainers/GNNExplainer.py | from math import sqrt
import torch
import torch_geometric as ptgeom
from torch import nn
from torch.optim import Adam
from torch_geometric.data import Data
from torch_geometric.nn import MessagePassing
from tqdm import tqdm
from ExplanationEvaluation.explainers.BaseExplainer import BaseExplainer
from ExplanationEvalu... | 6,676 | 40.216049 | 180 | py |
RE-ParameterizedExplainerForGraphNeuralNetworks | RE-ParameterizedExplainerForGraphNeuralNetworks-main/ExplanationEvaluation/explainers/PGExplainer.py | import torch
import torch_geometric as ptgeom
from torch import nn
from torch.optim import Adam
from torch_geometric.data import Data
from tqdm import tqdm
from ExplanationEvaluation.explainers.BaseExplainer import BaseExplainer
from ExplanationEvaluation.utils.graph import index_edge
class PGExplainer(BaseExplainer)... | 9,291 | 43.673077 | 180 | py |
RE-ParameterizedExplainerForGraphNeuralNetworks | RE-ParameterizedExplainerForGraphNeuralNetworks-main/ExplanationEvaluation/datasets/utils.py | import numpy as np
import scipy.sparse as sp
import torch
import scipy
import pickle as pkl
from scipy.sparse import coo_matrix
"""
Most of the functions in this module are copied from the PGExplainer code base. This ensures that the data is handled in the same way.
link: https://github.com/flyingdoog/PGExplainer
"""... | 6,827 | 31.669856 | 134 | py |
RE-ParameterizedExplainerForGraphNeuralNetworks | RE-ParameterizedExplainerForGraphNeuralNetworks-main/ExplanationEvaluation/utils/plotting.py | import networkx as nx
import torch
import numpy as np
import matplotlib.pyplot as plt
from pathlib import Path
"""
The function in this file is largely copied from the orginal PGExplainer codebase. The decision was made to largely copy this file to ensure
that the graph visualization between the original and replicat... | 5,945 | 35.478528 | 140 | py |
RE-ParameterizedExplainerForGraphNeuralNetworks | RE-ParameterizedExplainerForGraphNeuralNetworks-main/ExplanationEvaluation/utils/graph.py | import torch
def index_edge(graph, pair):
return torch.where((graph.T == pair).all(dim=1))[0]
| 99 | 19 | 55 | py |
RE-ParameterizedExplainerForGraphNeuralNetworks | RE-ParameterizedExplainerForGraphNeuralNetworks-main/ExplanationEvaluation/tasks/training.py | import os
import torch
import numpy as np
from torch_geometric.data import Data, DataLoader
from ExplanationEvaluation.datasets.dataset_loaders import load_dataset
from ExplanationEvaluation.models.model_selector import model_selector
def create_data_list(graphs, features, labels, mask):
"""
Convert the nump... | 9,155 | 36.52459 | 108 | py |
RE-ParameterizedExplainerForGraphNeuralNetworks | RE-ParameterizedExplainerForGraphNeuralNetworks-main/ExplanationEvaluation/tasks/replication.py | import time
import json
import os
import torch
import numpy as np
from tqdm import tqdm
from ExplanationEvaluation.datasets.dataset_loaders import load_dataset
from ExplanationEvaluation.datasets.ground_truth_loaders import load_dataset_ground_truth
from ExplanationEvaluation.evaluation.AUCEvaluation import AUCEvalua... | 8,334 | 38.316038 | 180 | py |
furniture-bench | furniture-bench-main/run.py | import isaacgym
import torch
import os
import hydra
from omegaconf import OmegaConf, DictConfig
import furniture_bench
from furniture_bench.utils.checkpoint import download_ckpt_if_not_exists
@hydra.main(config_path="config", config_name="default_config")
def main(cfg: DictConfig) -> None:
if cfg.num_threads > ... | 1,468 | 27.803922 | 79 | py |
furniture-bench | furniture-bench-main/rolf/rolf/main.py | """ Launch RL/IL training and evaluation. """
import sys
import signal
import os
import logging
import time
from pathlib import Path
import numpy as np
import torch
import wandb
import hydra
from six.moves import shlex_quote
from mpi4py import MPI
from omegaconf import OmegaConf, DictConfig
from .trainer import Trai... | 5,539 | 29.43956 | 83 | py |
furniture-bench | furniture-bench-main/rolf/rolf/trainer.py | """
Base code for RL/IL training.
Collects rollouts and updates policy networks.
"""
import pickle
from pathlib import Path
import torch
import wandb
import h5py
import imageio
import numpy as np
from tqdm import tqdm
from .algorithms import RL_ALGOS, IL_ALGOS
from .utils import Logger, Every, StopWatch, Info, LOG_T... | 13,222 | 37.438953 | 88 | py |
furniture-bench | furniture-bench-main/rolf/rolf/networks/distributions.py | from collections import OrderedDict
import numpy as np
import torch
import torch.nn as nn
import torch.distributions
# Identity
class Identity(object):
def __init__(self, mean):
self.mean = mean
def mode(self):
return self.mean
def sample(self):
return self.mean.detach()
de... | 5,276 | 26.773684 | 88 | py |
furniture-bench | furniture-bench-main/rolf/rolf/networks/discriminator.py | import numpy as np
import torch
import torch.nn as nn
import gym.spaces
from .utils import MLP
class Discriminator(nn.Module):
def __init__(
self,
ob_space,
ob_next_space=None,
ac_space=None,
mlp_dims=[256, 256],
activation="tanh",
):
super().__init__()... | 1,567 | 27.509091 | 63 | py |
furniture-bench | furniture-bench-main/rolf/rolf/networks/dreamer.py | from collections import OrderedDict
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import gym.spaces
from .utils import MLP, get_activation
from .distributions import Normal, TanhNormal, SampleDist, MixedDistribution
from ..utils import Logger
from ..utils.dreamer import static... | 12,733 | 32.598945 | 106 | py |
furniture-bench | furniture-bench-main/rolf/rolf/networks/actor_critic.py | from collections import OrderedDict
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import gym.spaces
from .distributions import Categorical, Normal, TanhNormal, MixedDistribution
from .distributions import Identity, TanhIdentity
from .utils import MLP, flatten_ac, get_activation... | 5,697 | 33.957055 | 94 | py |
furniture-bench | furniture-bench-main/rolf/rolf/networks/utils.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision.models import resnet18
activation_map = {
"relu": nn.ReLU,
"leakyrelu": nn.LeakyReLU,
"elu": nn.ELU,
"tanh": nn.Tanh,
"sigmoid": nn.Sigmoid,
}
def get_activation(activation):
if activation ... | 6,256 | 27.967593 | 83 | py |
furniture-bench | furniture-bench-main/rolf/rolf/networks/encoder.py | """
Code reference:
https://github.com/MishaLaskin/rad/blob/master/encoder.py
"""
import gym.spaces
from rolf.utils.aug import RandomShiftsAug
import torch
import torch.nn as nn
from .utils import CNN, R3M, VIP, ResNet18
class Encoder(nn.Module):
def __init__(self, cfg, ob_space):
super().__init__()
... | 3,585 | 36.354167 | 102 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/dac_agent.py | from collections import OrderedDict
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torch.autograd as autograd
import torch.distributions
from torch.optim.lr_scheduler import StepLR
import gym.spaces
from .base_agent import BaseAgent
from .ddpg_... | 10,337 | 33.575251 | 87 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/iris_agent.py | from collections import OrderedDict
import pickle
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import gym.spaces
from torch.optim.lr_scheduler import StepLR
from .base_agent import BaseAgent
from .rollout import RolloutRunner
from ..algorithms.datas... | 8,940 | 32.996198 | 101 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/gail_agent.py | from collections import OrderedDict
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import torch.autograd as autograd
import torch.distributions
from torch.optim.lr_scheduler import StepLR
from .base_agent import BaseAgent
from .ppo_agent import PPOAgent
from .dataset import ReplayBu... | 12,409 | 33.761905 | 88 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/dataset.py | from collections import defaultdict, deque
from functools import partial
import numpy as np
import tensorflow as tf
import torch.utils.data
from ..utils import Logger
def _convert(value, precision):
if isinstance(value, dict):
return {k: _convert(v, precision) for k, v in value.items()}
value = np.... | 12,742 | 34.201657 | 92 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/base_agent.py | from pathlib import Path
import torch
import numpy as np
from .rollout import RolloutRunner
from ..utils import Logger, Normalizer, Once
from ..utils.pytorch import to_tensor, sync_network
class BaseAgent(torch.nn.Module):
"""Base class for agents."""
def __init__(self, cfg, ob_space=None):
super()... | 3,776 | 31.008475 | 88 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/dreamer_agent.py | # Dreamer code reference:
# https://github.com/danijar/dreamer/blob/master/dreamer.py
# TODO: pcont is not implemented yet
import numpy as np
import torch
import gym.spaces
from .base_agent import BaseAgent
from .dataset import ReplayBufferEpisode, SeqSampler
from .dreamer_rollout import DreamerRolloutRunner
from ..n... | 12,810 | 41.989933 | 461 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/prior_agent.py | import os
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim.lr_scheduler import StepLR
from .base_agent import BaseAgent
from spirl.models.closed_loop_spirl_mdl import ImageClSPiRLMdl, ClSPiRLMdl
from data.dataloader import (
GlobalSplitVideoDataset,
) # need to s... | 4,598 | 32.086331 | 87 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/sac_agent.py | # SAC training code reference
# https://github.com/vitchyr/rlkit/blob/master/rlkit/torch/sac/sac.py
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import gym.spaces
from .base_agent import BaseAgent
from .dataset import ReplayBuffer, RandomSampler
fro... | 9,199 | 35.653386 | 88 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/ddpg_agent.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import gym.spaces
from torch.optim.lr_scheduler import StepLR
from .base_agent import BaseAgent
from .dataset import ReplayBuffer, RandomSampler
from ..networks import Actor, Critic
from ..utils import Log... | 11,372 | 36.166667 | 88 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/bc_agent.py | from collections import OrderedDict
import pickle
import numpy as np
from rolf.algorithms.dataset import SeqSampler
import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data.sampler import SubsetRandomSampler
from ..algorithms.dataset import ReplayBufferEpisode, SeqSampler
from torch.optim.l... | 6,432 | 37.291667 | 95 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/spirl_agent.py | from pathlib import Path
import copy
import torch
from spirl.rl.components.agent import FixedIntervalHierarchicalAgent
from spirl.rl.components.replay_buffer import UniformReplayBuffer
from spirl.rl.policies.cl_model_policies import ACClModelPolicy
from spirl.rl.policies.prior_policies import ACLearnedPriorAugmentedPI... | 9,247 | 32.507246 | 123 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/expert_dataset.py | import pickle
from collections import deque, OrderedDict
from pathlib import Path
import torch
from torch.utils.data import Dataset
import numpy as np
import gym.spaces
from ..utils import Logger
from ..utils.gym_env import get_non_absorbing_state, get_absorbing_state, zero_value
class ExpertDataset(Dataset):
"... | 6,901 | 37.344444 | 141 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/dreamer_rollout.py | """
Runs rollouts (RolloutRunner class) and collects transitions using Rollout class.
"""
import numpy as np
import gym.spaces
from .rollout import Rollout, RolloutRunner
from ..utils import Logger, Info, Every
from ..utils.pytorch import check_memory_kill_switch
class DreamerRolloutRunner(RolloutRunner):
"""Ro... | 6,140 | 31.664894 | 90 | py |
furniture-bench | furniture-bench-main/rolf/rolf/algorithms/ppo_agent.py | import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim.lr_scheduler import StepLR
from ..networks import Actor, Critic
from ..utils import Logger, Info
from ..utils.mpi import mpi_average
from ..utils.pytorch import count_parameters, dictlist_to_tensor, optimizer_cuda
from .... | 9,524 | 32.304196 | 88 | py |
furniture-bench | furniture-bench-main/rolf/rolf/utils/aug.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class RandomShiftsAug(nn.Module):
"""
Random shift image augmentation.
Adapted from https://github.com/facebookresearch/drqv2
"""
def __init__(self):
super().__init__()
self.pad = 8
def forward(self, x):
if not self.pad:
return x
n, ... | 974 | 30.451613 | 102 | py |
furniture-bench | furniture-bench-main/rolf/rolf/utils/pytorch.py | import io
import psutil
import time
from pathlib import Path
from collections import OrderedDict
import numpy as np
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torch.distributed as dist
import torchvision.utils as vutils
import torchvision.transforms.functional... | 15,050 | 29.406061 | 101 | py |
furniture-bench | furniture-bench-main/rolf/rolf/utils/dreamer.py | import torch
import tensorflow as tf
def static_scan(fn, inputs, start, reverse=False):
"""Applies `fn(state, input[t])` sequentially T times and returns intermediate states.
Args:
fn: Function to apply.
inputs: A list of T inputs.
start: A list of M initial states.
Returns M lis... | 1,515 | 32.688889 | 90 | py |
furniture-bench | furniture-bench-main/furniture_bench/envs/furniture_sim_env.py | try:
import isaacgym
from isaacgym import gymapi, gymtorch
except ImportError as e:
from rich import print
print(
"""[red][Isaac Gym Import Error]
1. You need to install Isaac Gym, if not installed.
- Download Isaac Gym following https://clvrai.github.io/furniture-bench/docs/getting_start... | 53,956 | 39.236391 | 170 | py |
furniture-bench | furniture-bench-main/furniture_bench/envs/policy_envs/furniture_bench_image_feature.py | import numpy as np
from gym import spaces
import torch
from furniture_bench.envs.furniture_bench_env import FurnitureBenchEnv
from furniture_bench.config import config
from furniture_bench.robot.robot_state import filter_and_concat_robot_state
from furniture_bench.robot.panda import PandaError
class FurnitureBenchI... | 2,360 | 33.720588 | 84 | py |
furniture-bench | furniture-bench-main/furniture_bench/envs/policy_envs/furniture_sim_image_feature.py | import numpy as np
from gym import spaces
import torch
from furniture_bench.config import config
from furniture_bench.envs.furniture_sim_env import FurnitureSimEnv
from furniture_bench.perception.image_utils import resize, resize_crop
from furniture_bench.robot.robot_state import filter_and_concat_robot_state
class... | 2,336 | 32.385714 | 82 | py |
furniture-bench | furniture-bench-main/furniture_bench/envs/legacy_envs/furniture_sim_legacy_env.py | """The environment used in the main paper. Deprecated in favor of simpler and consistent API."""
try:
import isaacgym
from isaacgym import gymapi, gymtorch
except ImportError as e:
from rich import print
print("[red][Isaac Gym Import Error][/red]")
print("[red]1. You need to install Isaac Gym, if n... | 51,627 | 39.651969 | 172 | py |
furniture-bench | furniture-bench-main/furniture_bench/scripts/run_sim_env.py | """Instantiate FurnitureSim-v0 and test various functionalities."""
import argparse
import pickle
import furniture_bench
import gym
import cv2
import torch
import numpy as np
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--furniture", default="square_table")
parser.add_argument(
... | 4,660 | 28.878205 | 85 | py |
furniture-bench | furniture-bench-main/furniture_bench/furniture/parts/round_table_base.py | import numpy as np
import torch
from furniture_bench.utils.pose import get_mat, rot_mat
from furniture_bench.furniture.parts.part import Part
import furniture_bench.utils.transform as T
import furniture_bench.controllers.control_utils as C
class RoundTableBase(Part):
def __init__(self, part_config, part_idx):
... | 7,961 | 39.212121 | 98 | py |
furniture-bench | furniture-bench-main/furniture_bench/furniture/parts/cabinet_body.py | import torch
import numpy as np
import numpy.typing as npt
from furniture_bench.utils.pose import get_mat, is_similar_pos, is_similar_rot, rot_mat
from furniture_bench.furniture.parts.part import Part
import furniture_bench.utils.transform as T
import furniture_bench.controllers.control_utils as C
from furniture_bench... | 4,518 | 34.865079 | 88 | py |
furniture-bench | furniture-bench-main/furniture_bench/furniture/parts/part.py | import copy
import pdb
from abc import ABC, abstractmethod
import numpy as np
import numpy.typing as npt
import torch
from furniture_bench.furniture.parts.pose_filter import PoseFilter
from furniture_bench.utils.pose import get_mat, is_similar_pos, is_similar_pose, rot_mat
from furniture_bench.utils.pose import is_si... | 11,077 | 36.299663 | 97 | py |
furniture-bench | furniture-bench-main/furniture_bench/furniture/parts/table_top.py | import numpy as np
import numpy.typing as npt
import torch
from numpy.linalg import inv
import furniture_bench.utils.transform as T
import furniture_bench.controllers.control_utils as C
from furniture_bench.utils.pose import get_mat, is_similar_rot, rot_mat
from furniture_bench.config import config
from furniture_benc... | 6,691 | 36.177778 | 88 | py |
furniture-bench | furniture-bench-main/furniture_bench/furniture/parts/leg.py | import torch
import numpy as np
import numpy.typing as npt
from furniture_bench.furniture.parts.part import Part
from furniture_bench.utils.pose import get_mat, is_similar_rot, is_similar_xz, rot_mat
from furniture_bench.config import config
import furniture_bench.utils.transform as T
import furniture_bench.controller... | 13,715 | 38.188571 | 104 | py |
furniture-bench | furniture-bench-main/furniture_bench/robot/panda.py | import math
import time
from typing import List, Optional, Tuple, Union
import numpy as np
import numpy.typing as npt
import torch
from furniture_bench.utils.pose import is_similar_rot, rot_mat
from furniture_bench.config import config
from furniture_bench.controllers.osc import osc_factory
from furniture_bench.envs.... | 15,529 | 33.282561 | 89 | py |
furniture-bench | furniture-bench-main/furniture_bench/controllers/control_utils.py | """Code derived from https://github.com/StanfordVL/perls2 and https://github.com/ARISE-Initiative/robomimic
Utility functions for controlling the robot.
"""
import math
import torch
@torch.jit.script
def opspace_matrices(mass_matrix, J_full):
"""Compute the lambda and nullspace matrices for the operational spac... | 11,952 | 29.648718 | 118 | py |
furniture-bench | furniture-bench-main/furniture_bench/controllers/osc.py | """Code derived from https://github.com/StanfordVL/perls2 and https://github.com/ARISE-Initiative/robomimic"""
import math
from typing import Dict, List
import torch
import furniture_bench.controllers.control_utils as C
def osc_factory(real_robot=True, *args, **kwargs):
if real_robot:
import torchcontro... | 10,127 | 43.227074 | 152 | py |
furniture-bench | furniture-bench-main/furniture_bench/utils/transform.py | """
Utility functions of matrix and vector transformations.
Based on the utility functions from Robosuite (https://github.com/StanfordVL/robosuite)
NOTE: convention for quaternions is (x, y, z, w)
"""
import math
from typing import Union
import numpy as np
import numpy.typing as npt
import numba
PI = np.pi
EPS = np.... | 26,915 | 27.362487 | 119 | py |
furniture-bench | furniture-bench-main/furniture_bench/utils/random.py | import random
import numpy as np
import torch
def set_seed(seed):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
| 144 | 12.181818 | 27 | py |
furniture-bench | furniture-bench-main/furniture_bench/data/data_collector.py | """Define data collection class that rollout the environment, get action from the interface (e.g., teleoperation, automatic scripts), and save data."""
import time
import pickle
from datetime import datetime
from pathlib import Path
import cv2
import gym
import torch
from joblib import Parallel, delayed
from furnitur... | 13,269 | 37.352601 | 170 | py |
furniture-bench | furniture-bench-main/vip/vip/train_vip.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# 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 warnings
warnings.filterwarnings('ignore', category=DeprecationWarning)
import os
os.environ['MKL_SERVICE_FORCE_INT... | 4,961 | 33.699301 | 147 | py |
furniture-bench | furniture-bench-main/vip/vip/__init__.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# 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 vip.models.model_vip import VIP
import os
from os.path import expanduser
import omegaconf
import hydra
import gdown
... | 2,486 | 35.043478 | 104 | py |
furniture-bench | furniture-bench-main/vip/vip/trainer.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
# 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
from numpy.core.numeric import full
import torch
import torch.nn as nn
import torch.nn.functional as F
i... | 3,327 | 32.616162 | 142 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.