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 |
|---|---|---|---|---|---|---|
ELLA | ELLA-main/babyai/babyai/imitation.py | import copy
import gym
import time
import datetime
import numpy as np
import sys
import itertools
import torch
from babyai.evaluate import batch_evaluate
import babyai.utils as utils
from babyai.rl import DictList
from babyai.model import ACModel
from gym_minigrid.wrappers import FullyObsImgDirWrapper, FullyObsImgEgoWr... | 21,535 | 44.627119 | 131 | py |
ELLA | ELLA-main/babyai/babyai/shaped_env.py | import gym
import torch
import numpy as np
from copy import deepcopy
from torch.multiprocessing import Process, Pipe
import torch.nn.functional as F
import logging
import babyai.utils
logger = logging.getLogger(__name__)
logger.setLevel(logging.WARNING)
def multi_worker(conn, envs):
"""Target for a subprocess th... | 20,229 | 44.15625 | 97 | py |
ELLA | ELLA-main/babyai/babyai/model.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torch.distributions import Categorical, Normal
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
import babyai.rl
from babyai.rl.utils.supervised_losses import required_h... | 17,057 | 41.75188 | 117 | py |
ELLA | ELLA-main/babyai/babyai/hrl.py | """
Note: This file is deprecated, but is retained for development reference.
"""
import math
import operator
from functools import reduce
from torch.multiprocessing import Process, Pipe
import torch
import numpy as np
import gym
from tqdm import tqdm
from gym import error, spaces, utils
from babyai.utils.agent impor... | 22,042 | 50.025463 | 195 | py |
ELLA | ELLA-main/babyai/babyai/utils/format.py | import os
import json
import numpy
import re
import torch
import babyai.rl
from .. import utils
def get_vocab_path(model_name):
return os.path.join(utils.get_model_dir(model_name), "vocab.json")
class Vocabulary:
def __init__(self, model_name):
self.path = get_vocab_path(model_name)
self.ma... | 9,017 | 35.510121 | 145 | py |
ELLA | ELLA-main/babyai/babyai/utils/model.py | import os
import torch
import wandb
from .. import utils
def get_model_dir(model_name):
return os.path.join(utils.storage_dir(), "models", model_name)
def get_model_path(model_name):
return os.path.join(get_model_dir(model_name), "model.pt")
def load_model(model_name, raise_not_found=True):
path = ge... | 756 | 21.939394 | 72 | py |
ELLA | ELLA-main/babyai/babyai/utils/agent.py | from abc import ABC, abstractmethod
import torch
from .. import utils
from babyai.bot import Bot
from babyai.model import ACModel
from random import Random
class Agent(ABC):
"""An abstraction of the behavior of an agent. The agent is able:
- to choose an action given an observation,
- to analyze the feedb... | 6,446 | 32.931579 | 104 | py |
ELLA | ELLA-main/babyai/babyai/utils/__init__.py | import os
import random
import numpy
import torch
from babyai.utils.agent import load_agent, ModelAgent, DemoAgent, BotAgent
from babyai.utils.demos import (
load_demos, save_demos, synthesize_demos, get_demos_path)
from babyai.utils.format import ObssPreprocessor, ObssContPreprocessor, ObssDirPreprocessor, IntObss... | 1,059 | 33.193548 | 157 | py |
ELLA | ELLA-main/babyai/babyai/rl/format.py | import torch
def default_preprocess_obss(obss, device=None):
return torch.tensor(obss, device=device) | 106 | 25.75 | 47 | py |
ELLA | ELLA-main/babyai/babyai/rl/model.py | from abc import abstractmethod, abstractproperty
import torch.nn as nn
import torch.nn.functional as F
class ACModel:
recurrent = False
@abstractmethod
def __init__(self, obs_space, action_space):
pass
@abstractmethod
def forward(self, obs):
pass
class RecurrentACModel(ACModel):
... | 485 | 17.692308 | 48 | py |
ELLA | ELLA-main/babyai/babyai/rl/algos/base.py | from abc import ABC, abstractmethod
import torch
import numpy
from tqdm import tqdm
from babyai.rl.format import default_preprocess_obss
from babyai.rl.utils import DictList, ParallelEnv
from babyai.rl.utils.supervised_losses import ExtraInfoCollector
import babyai.utils
from torch.distributions import Categorical
imp... | 13,607 | 42.476038 | 145 | py |
ELLA | ELLA-main/babyai/babyai/rl/algos/ppo.py | import numpy
import torch
import torch.nn.functional as F
import logging
logger = logging.getLogger(__name__)
from tqdm import tqdm
from babyai.rl.algos.base import BaseAlgo
class PPOAlgo(BaseAlgo):
"""The class for the Proximal Policy Optimization algorithm
([Schulman et al., 2015](https://arxiv.org/abs/170... | 8,221 | 43.443243 | 143 | py |
ELLA | ELLA-main/babyai/babyai/rl/utils/supervised_losses.py | import torch
import torch.nn.functional as F
import numpy
from babyai.rl.utils import DictList
# dictionary that defines what head is required for each extra info used for auxiliary supervision
required_heads = {'seen_state': 'binary',
'see_door': 'binary',
'see_obj': 'binary',
... | 8,264 | 45.432584 | 116 | py |
ELLA | ELLA-main/babyai/babyai/rl/utils/penv.py | from torch.multiprocessing import Process, Pipe
import gym
from tqdm import tqdm
import logging
import torch
from tqdm import tqdm
logger = logging.getLogger(__name__)
import concurrent.futures
# For multiprocessing
def worker(conn, env):
while True:
cmd, data = conn.recv()
if cmd == "step":
... | 3,292 | 32.948454 | 116 | py |
ELLA | ELLA-main/babyai/scripts/train_subtask_prediction_model.py | #!/usr/bin/env python3
"""
Pre-training code for the subtask prediction model (relevance classifier).
"""
import os
import csv
import copy
import gym
import time
import datetime
import numpy as np
import sys
import logging
import torch
from babyai.arguments import ArgumentParser
import babyai.utils as utils
from sub... | 3,878 | 38.581633 | 124 | py |
ELLA | ELLA-main/babyai/scripts/train_il.py | #!/usr/bin/env python3
"""
Script to train agent through imitation learning using demonstrations.
"""
import os
import csv
import copy
import gym
import time
import datetime
import numpy as np
import sys
import logging
import torch
from babyai.arguments import ArgumentParser
import babyai.utils as utils
from babyai.i... | 4,524 | 40.898148 | 120 | py |
ELLA | ELLA-main/babyai/scripts/train_intelligent_expert.py | #!/usr/bin/env python3
"""
Train an agent using an intelligent expert.
The procedure starts with a small set of training demonstrations, and
iteratively grows the training set by some percentage. At every step, the new
demos used to grow the training set are demos the agent is currently failing
on. A new model is tra... | 9,824 | 34.469314 | 123 | py |
ELLA | ELLA-main/babyai/scripts/learn_baseline_model.py | """
A reimplmentation of the LEARN model (Goyal et al., 2019)
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
def initialize_parameters(m):
classname = m.__class__.__name__
if classname.find('Linear') != -1:
torch.nn.init.xavier_uniform_(m.we... | 2,745 | 36.108108 | 124 | py |
ELLA | ELLA-main/babyai/scripts/train_rl.py | #!/usr/bin/env python3
"""
Script to train the agent through reinforcement learning.
"""
import os
import logging
import csv
import json
import gym
import time
import datetime
import torch
import babyai
import babyai.utils as utils
import babyai.rl
from babyai.arguments import ArgumentParser
from babyai.model import... | 23,649 | 49 | 158 | py |
ELLA | ELLA-main/babyai/scripts/make_agent_demos.py | #!/usr/bin/env python3
"""
Generate a set of agent demonstrations.
The agent can either be a trained model or the heuristic expert (bot).
Demonstration generation can take a long time, but it can be parallelized
if you have a cluster at your disposal. Provide a script that launches
make_agent_demos.py at your cluste... | 11,172 | 39.190647 | 127 | py |
ELLA | ELLA-main/babyai/scripts/learn_baseline.py | """
Training interface for the LEARN model (Goyal et al., 2019)
"""
import copy
import gym
import time
import datetime
import numpy as np
import sys
import itertools
import torch
import torch.nn as nn
import babyai.utils as utils
import os
import json
import logging
import wandb
from tqdm import tqdm
from gym import s... | 11,779 | 42.150183 | 154 | py |
ELLA | ELLA-main/babyai/scripts/instruction_handler.py | """
General class for handling instructions provided by demonstrations.
"""
import pickle
import os
import numpy as np
from babyai import utils
# from transformers import BertTokenizer, BertModel
from torch.nn import CosineSimilarity
import torch
import logging
logging.getLogger("transformers").setLevel(logging.WARNIN... | 9,548 | 44.255924 | 134 | py |
ELLA | ELLA-main/babyai/scripts/make_subtask_recipe_demos.py | #!/usr/bin/env python3
"""
Generate a set of subtask decompositions -- via an oracle or a
low-level/termination policy.
"""
import argparse
import gym
import logging
import sys
import os
import time
import numpy as np
import torch
from tqdm import tqdm
import babyai.utils as utils
from babyai.utils.agent import Model... | 8,556 | 47.073034 | 149 | py |
ELLA | ELLA-main/babyai/scripts/train_learn_baseline_model.py | #!/usr/bin/env python3
"""
Training code for the LEARN model (Goyal et al., 2019)
"""
import os
import csv
import copy
import gym
import time
import datetime
import numpy as np
import sys
import logging
import torch
import wandb
from babyai.arguments import ArgumentParser
import babyai.utils as utils
from learn_base... | 2,558 | 31.392405 | 121 | py |
ELLA | ELLA-main/babyai/scripts/subtask_prediction_model.py | """
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
def initialize_parameters(m):
classname = m.__class__.__name__
if classname.find('Linear') != -1:
m.weight.data.normal_(0, 1)
m.weight.data *= 1 / torch.sqrt(m.weight.data.pow(2).sum... | 2,764 | 34.448718 | 87 | py |
ELLA | ELLA-main/babyai/scripts/subtask_prediction.py | """
Code for the subtask prediction model (relevance classifier).
"""
import copy
import gym
import time
import datetime
import numpy as np
import sys
import itertools
import torch
import torch.nn as nn
import babyai.utils as utils
import os
import json
import logging
from tqdm import tqdm
from gym import spaces
from ... | 21,818 | 42.464143 | 147 | py |
keras-retinanet | keras-retinanet-main/setup.py | import setuptools
from setuptools.extension import Extension
from distutils.command.build_ext import build_ext as DistUtilsBuildExt
class BuildExtension(setuptools.Command):
description = DistUtilsBuildExt.description
user_options = DistUtilsBuildExt.user_options
boolean_options = DistUtilsBuildExt... | 2,420 | 34.602941 | 116 | py |
keras-retinanet | keras-retinanet-main/examples/resnet50_retinanet.py | #!/usr/bin/env python
# coding: utf-8
# Load necessary modules
import sys
sys.path.insert(0, '../')
# import keras_retinanet
from keras_retinanet import models
from keras_retinanet.utils.image import read_image_bgr, preprocess_image, resize_image
from keras_retinanet.utils.visualization import draw_box, draw_captio... | 3,514 | 31.850467 | 1,189 | py |
keras-retinanet | keras-retinanet-main/tests/test_losses.py | import keras_retinanet.losses
from tensorflow import keras
import numpy as np
import pytest
def test_smooth_l1():
regression = np.array([
[
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
]
], dtype=keras.backend.floatx())
regressio... | 836 | 23.617647 | 83 | py |
keras-retinanet | keras-retinanet-main/tests/models/test_mobilenet.py | """
Copyright 2017-2018 lvaleriu (https://github.com/lvaleriu/)
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,817 | 30.344828 | 96 | py |
keras-retinanet | keras-retinanet-main/tests/models/test_densenet.py | """
Copyright 2018 vidosits (https://github.com/vidosits/)
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 agree... | 1,587 | 29.538462 | 96 | py |
keras-retinanet | keras-retinanet-main/tests/backend/test_common.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 3,822 | 29.830645 | 72 | py |
keras-retinanet | keras-retinanet-main/tests/bin/test_train.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 2,229 | 22.473684 | 72 | py |
keras-retinanet | keras-retinanet-main/tests/layers/test_misc.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 6,877 | 31.29108 | 85 | py |
keras-retinanet | keras-retinanet-main/tests/layers/test_filter_detections.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 6,618 | 37.04023 | 106 | py |
keras-retinanet | keras-retinanet-main/tests/utils/test_transform.py | import numpy as np
from numpy.testing import assert_almost_equal
from math import pi
from keras_retinanet.utils.transform import (
colvec,
transform_aabb,
rotation, random_rotation,
translation, random_translation,
scaling, random_scaling,
shear, random_shear,
random_flip,
random_transf... | 5,871 | 37.631579 | 117 | py |
keras-retinanet | keras-retinanet-main/tests/utils/test_anchors.py | import numpy as np
import configparser
from tensorflow import keras
from keras_retinanet.utils.anchors import anchors_for_shape, AnchorParameters
from keras_retinanet.utils.config import read_config_file, parse_anchor_parameters
def test_config_read():
config = read_config_file('tests/test-data/config/config.ini... | 8,819 | 50.882353 | 111 | py |
keras-retinanet | keras-retinanet-main/tests/preprocessing/test_csv_generator.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 7,141 | 32.064815 | 138 | py |
keras-retinanet | keras-retinanet-main/tests/preprocessing/test_image.py | import os
import pytest
from PIL import Image
from keras_retinanet.utils import image
import numpy as np
_STUB_IMG_FNAME = 'stub-image.jpg'
@pytest.fixture(autouse=True)
def run_around_tests(tmp_path):
"""Create a temp image for test"""
rand_img = np.random.randint(0, 255, (3, 3, 3), dtype='uint8')
Image... | 742 | 26.518519 | 75 | py |
keras-retinanet | keras-retinanet-main/tests/preprocessing/test_generator.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 9,224 | 32.791209 | 146 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/initializers.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 1,149 | 28.487179 | 110 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/losses.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 4,762 | 39.02521 | 150 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/callbacks/common.py | from tensorflow import keras
class RedirectModel(keras.callbacks.Callback):
"""Callback which wraps another callback, but executed on a different model.
```python
model = keras.models.load_model('model.h5')
model_checkpoint = ModelCheckpoint(filepath='snapshot.h5')
parallel_model = multi_gpu_mode... | 1,433 | 29.510638 | 92 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/callbacks/eval.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 4,038 | 39.39 | 118 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/callbacks/coco.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 2,841 | 42.060606 | 106 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/models/resnet.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 4,913 | 36.227273 | 153 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/models/vgg.py | """
Copyright 2017-2018 cgratie (https://github.com/cgratie/)
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... | 3,925 | 35.691589 | 153 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/models/densenet.py | """
Copyright 2018 vidosits (https://github.com/vidosits/)
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 agree... | 4,403 | 38.321429 | 153 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/models/retinanet.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 16,776 | 40.527228 | 146 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/models/senet.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 6,524 | 39.277778 | 153 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/models/effnet.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 6,778 | 41.36875 | 153 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/models/__init__.py | from __future__ import print_function
import sys
class Backbone(object):
""" This class stores additional information on backbones.
"""
def __init__(self, backbone):
# a dictionary mapping custom layer names to the correct classes
from .. import layers
from .. import losses
... | 4,755 | 36.746032 | 142 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/models/mobilenet.py | """
Copyright 2017-2018 lvaleriu (https://github.com/lvaleriu/)
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,456 | 37.756522 | 153 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/backend/backend.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 4,912 | 39.941667 | 166 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/bin/evaluate.py | #!/usr/bin/env python
"""
Copyright 2017-2018 Fizyr (https://fizyr.com)
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 ... | 8,632 | 40.705314 | 172 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/bin/convert_model.py | #!/usr/bin/env python
"""
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicabl... | 3,821 | 36.841584 | 148 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/bin/debug.py | #!/usr/bin/env python
"""
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicabl... | 13,478 | 40.860248 | 205 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/bin/train.py | #!/usr/bin/env python
"""
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicabl... | 23,735 | 41.844765 | 188 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/layers/_misc.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 6,912 | 35.967914 | 112 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/layers/filter_detections.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 9,795 | 41.777293 | 156 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/utils/anchors.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 13,364 | 37.185714 | 159 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/utils/visualization.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 4,222 | 38.46729 | 136 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/utils/image.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 11,651 | 31.638655 | 137 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/utils/transform.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 10,437 | 34.993103 | 117 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/utils/config.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 2,101 | 35.241379 | 114 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/utils/eval.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 9,696 | 38.579592 | 155 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/utils/coco_eval.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 3,233 | 33.404255 | 108 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/preprocessing/generator.py | """
Copyright 2017-2018 Fizyr (https://fizyr.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in w... | 15,412 | 39.348168 | 171 | py |
keras-retinanet | keras-retinanet-main/keras_retinanet/preprocessing/csv_generator.py | """
Copyright 2017-2018 yhenon (https://github.com/yhenon/)
Copyright 2017-2018 Fizyr (https://fizyr.com)
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-... | 7,634 | 32.783186 | 139 | py |
Excitatory-inhibitory | Excitatory-inhibitory-main/generate_figures.py | import os
import time
import fnmatch
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from pylab import grid
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
from pylab import grid
from scipy.stats import norm
from scipy.stats import norm, skew, kurtosis
from numpy import l... | 42,919 | 43.156379 | 222 | py |
Excitatory-inhibitory | Excitatory-inhibitory-main/binary_and_recurrent_exi_ini_01.py | ##########################################################
# Author C. Jarne #
# binary_and_recurrent_main.py (ver 2.0) #
# Based on a Keras-Cog task from Alexander Atanasov #
# An "and" task (low edge triggered) # ... | 14,625 | 43.455927 | 302 | py |
Excitatory-inhibitory | Excitatory-inhibitory-main/print_status_2_inputs_paper_exc_inh.py | #A code for print network status when different data set input samples are applied
# Plot of Individual neural state for the interation that you defined in load and print
# Plot of SVD in 2 and 3D
# Plot of PCA in 3D
from PIL import Image
import time
import numpy as np
import matplotlib.pyplot as plt
from pylab import... | 24,525 | 36.048338 | 167 | py |
SELENE | SELENE-main/code/main.py | #!/usr/bin/env python
# coding: utf-8
import argparse
import sys
import numpy as np
import random
import time
import multiprocessing as mp
import torch
torch.multiprocessing.set_sharing_strategy('file_system')
torch.set_num_threads(1)
from dataset import load_nc_data
from utils import seed, get_hop_num, save_LOG, st... | 7,771 | 34.815668 | 137 | py |
SELENE | SELENE-main/code/unsuphne_feat_utils.py | import os
import numpy as np
import networkx as nx
from tqdm import tqdm
import multiprocessing as mp
import time
from sklearn.preprocessing import normalize
from scipy.sparse import linalg
import torch
from torch import FloatTensor
import torch.nn.functional as F
from torch_cluster import random_walk
from torch_geom... | 18,502 | 36.915984 | 120 | py |
SELENE | SELENE-main/code/load_nhb_data_utils.py | import scipy
import scipy.io
from sklearn.preprocessing import label_binarize
from google_drive_downloader import GoogleDriveDownloader as gdd
import scipy.io
import numpy as np
import scipy.sparse
import torch
from os import path
DATAPATH = '../data/NHB/'
class NCDataset(object):
def __init__(self, name, root=... | 5,187 | 34.77931 | 122 | py |
SELENE | SELENE-main/code/utils.py | import os
import argparse
import time
import numpy as np
import pandas as pd
import random
from six.moves import cPickle as pickle
import torch
def save_dataloader(
data, data_loader, args
):
path = f'../data/preprocessed/{data.name}/' +\
f'bs-{args.batch_size}-feat-{args.feat_method}-' +\
... | 4,613 | 30.60274 | 110 | py |
SELENE | SELENE-main/code/dataset.py | import numpy as np
import random
import os
import scipy.sparse as sp
import networkx as nx
import pandas as pd
from sklearn import preprocessing
import torch
from torch_geometric.data import Data
import torch_geometric.transforms as T
from torch_geometric.utils import from_networkx
from torch_geometric.datasets import... | 13,544 | 36.008197 | 116 | py |
SELENE | SELENE-main/code/gnn_encoder.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_cluster import random_walk
from torch_geometric.nn import GCNConv, SAGEConv
from torch_geometric.loader import NeighborSampler as RawNeighborSampler
class AE(nn.Module):
def __init__(self, n_enc_1, n_enc_2, n_enc_3, n_dec_1, n_dec_2, n_... | 6,552 | 34.042781 | 91 | py |
SELENE | SELENE-main/code/unsuphne_nn_utils.py | from itertools import combinations
import torch
from torch import nn, Tensor, FloatTensor
from torch.nn import Linear, BatchNorm1d, LayerNorm, ReLU, PReLU
from torch_geometric.nn import GCNConv, GINConv, TAGConv, GATConv
EPS = 1e-15
class AE(nn.Module):
def __init__(
self, in_dim: int, hid_dim: int, ... | 6,550 | 34.994505 | 113 | py |
SELENE | SELENE-main/code/eval_tools.py | from typing import Dict
import numpy as np
from munkres import Munkres
from sklearn.metrics import accuracy_score, f1_score, normalized_mutual_info_score, adjusted_rand_score
from sklearn.svm import LinearSVC
from sklearn.cluster import KMeans
from sklearn import linear_model as sk_lm
from sklearn import metrics as sk... | 6,967 | 37.711111 | 121 | py |
SELENE | SELENE-main/code/unsuphne.py | import itertools
from typing import Dict, Optional, Tuple, Union
from pl_bolts.optimizers.lr_scheduler import LinearWarmupCosineAnnealingLR
import torch
from torch import nn, Tensor, FloatTensor
from torch.nn import Linear, BatchNorm1d, ReLU, PReLU, MSELoss
from torch_geometric.data import Data
from unsuphne_nn_utils ... | 11,714 | 34.935583 | 104 | py |
SELENE | SELENE-main/code/generate_syn_dataset_utils.py | # Copyright 2019 Sami Abu-El-Haija. All Rights Reserved.
# Original code & data: https://github.com/samihaija/mixhop/blob/master/data/synthetic
# Updated code: https://github.com/dongkwan-kim/SuperGAT/blob/master/SuperGAT/data_syn.py (we use)
import pickle
import random
import numpy as np
import networkx as nx
import ... | 7,669 | 36.783251 | 119 | py |
AutoCompressors | AutoCompressors-main/base_trainer.py | import functools
from collections.abc import Mapping
from distutils.util import strtobool
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union
from transformers import Trainer
# Integrations must be imported before ML frameworks:
import numpy as np
import torch
... | 23,624 | 41.798913 | 168 | py |
AutoCompressors | AutoCompressors-main/utils.py | import os
import re
def get_last_checkpoint_or_last_model(folder):
"""modification of get_last_checkpoint from transformer.trainer_utils.
This function will return the main folder if it contains files of the form "pytorch_model*". The default HF function ignores those and only looks
for "checkpoint-*" fold... | 1,316 | 34.594595 | 149 | py |
AutoCompressors | AutoCompressors-main/substep_trainer.py | from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from base_trainer import BaseTrainer
import math
import torch
from torch import nn
from torch.utils.data import Dataset
from transformers.trainer_utils import EvalPrediction
# from transformers.trainer_pt_utils import smp_forward_backward, smp_fo... | 10,645 | 44.495726 | 157 | py |
AutoCompressors | AutoCompressors-main/auto_compressor.py | import logging
import os
from typing import Optional, Union, List, Tuple
from dataclasses import dataclass
import torch
import torch.nn as nn
import torch.nn.functional as F
from transformers import OPTForCausalLM
from transformers.modeling_outputs import CausalLMOutputWithPast
import os
logger = logging.getLogger(... | 13,409 | 43.551495 | 169 | py |
AutoCompressors | AutoCompressors-main/train.py | import logging
import math
import os
import sys
import torch
import datasets
import transformers
from transformers import (
CONFIG_MAPPING,
AutoConfig,
AutoModelForCausalLM,
AutoTokenizer,
HfArgumentParser,
set_seed,
)
from transformers.utils import check_min_version, send_example_telemetry
fr... | 9,728 | 38.388664 | 113 | py |
GRETEL | GRETEL-main/local_main.py |
import sys
from src.evaluation.evaluator_manager import EvaluatorManager
print(f"Initializing test ensemble")
# config_file_path = './config/steel/meg-set-1/config_tree-cycles-500-32_tc-custom-oracle_meg_fold-0.json'
# config_file_path = './config/steel/cf2-bbbp/config_bbbp_gcn-tf_cf2_fold-9.json'
config_file_path ... | 7,163 | 35 | 143 | py |
GRETEL | GRETEL-main/src/explainer/explainer_cfgnnexplainer.py | import sys
import time
import networkx as nx
import numpy as np
import torch
import torch.optim as optim
from src.explainer.explainer_node import NodeExplainer
from src.oracle.oracle_node_pt import NodeOracle
from src.dataset.data_instance_node import NodeDataInstance
from src.dataset.dataset_base import Dataset
from ... | 9,859 | 38.44 | 141 | py |
GRETEL | GRETEL-main/src/explainer/explainer_gcountergan.py | from src.evaluation.evaluation_metric_base import EvaluationMetric
from src.explainer.explainer_base import Explainer
from src.dataset.dataset_base import Dataset
from src.oracle.oracle_base import Oracle
from src.dataset.data_instance_base import DataInstance
import numpy as np
import json
import pickle
import time
i... | 5,193 | 32.082803 | 185 | py |
GRETEL | GRETEL-main/src/explainer/explainer_clear.py | import os
from numbers import Number
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader, Dataset, TensorDataset
from torch_geometric.nn import DenseGCNConv, DenseGraphConv
from src.dataset.converters.causality_converter import \
DefaultCau... | 20,015 | 37.640927 | 165 | py |
GRETEL | GRETEL-main/src/explainer/explainer_cf2.py | import math
import os
import networkx as nx
import numpy as np
import torch
from dgl import from_networkx, to_networkx
from torch.utils.data import Dataset
from src.dataset.data_instance_base import DataInstance
from src.dataset.data_instance_features import DataInstanceWFeaturesAndWeights
from src.dataset.dataset_ba... | 8,106 | 35.85 | 97 | py |
GRETEL | GRETEL-main/src/explainer/explainer_node.py | import sys
import time
import networkx as nx
import numpy as np
import torch
import torch.optim as optim
from src.oracle.oracle_node_pt import NodeOracle
from src.dataset.data_instance_node import NodeDataInstance
from src.dataset.dataset_base import Dataset
from src.explainer.explainer_base import Explainer
from src.... | 852 | 31.807692 | 85 | py |
GRETEL | GRETEL-main/src/explainer/explainer_countergan.py | from src.explainer.explainer_base import Explainer
from src.dataset.dataset_base import Dataset
from src.oracle.oracle_base import Oracle
from src.dataset.data_instance_base import DataInstance
import numpy as np
from torch.utils.data import TensorDataset
import os
from torch.utils.data import Dataset, DataLoader
imp... | 19,295 | 36.250965 | 118 | py |
GRETEL | GRETEL-main/src/explainer/helpers/gcn_perturb.py | import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
from src.utils import get_degree_matrix, normalize_adj, create_symm_matrix_from_vec, create_vec_from_symm_matrix
from src.explainer.helpers.gcn import GraphConvolution, GCNSynthetic
class GraphConvol... | 6,074 | 33.714286 | 134 | py |
GRETEL | GRETEL-main/src/explainer/helpers/gcn.py | # Based on https://github.com/tkipf/pygcn/blob/master/pygcn/
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.parameter import Parameter
from torch_geometric.nn import GCNConv
class GraphConvolution(nn.Module):
"""
Simple GCN layer, similar to https://arxiv.org/abs... | 2,287 | 31.225352 | 77 | py |
GRETEL | GRETEL-main/src/explainer/meg/explainer_meg.py | import os
import numpy as np
import torch
import random
from src.dataset.data_instance_base import DataInstance
from src.explainer.meg.utils.queue import SortedQueue
from src.dataset.dataset_base import Dataset
from src.explainer.explainer_base import Explainer
from src.oracle.oracle_base import Oracle
class MEGExp... | 9,391 | 33.656827 | 128 | py |
GRETEL | GRETEL-main/src/explainer/meg/utils/fingerprints.py | import numpy as np
import torch
from rdkit.DataStructs import ConvertToNumpyArray
class Fingerprint:
def __init__(self, fingerprint, fp_length):
self.fp = fingerprint
self.fp_len = fp_length
def is_valid(self):
return self.fingerprint is None
def numpy(self):
np_ = np.zero... | 461 | 22.1 | 49 | py |
GRETEL | GRETEL-main/src/explainer/meg/utils/molecules.py | import sys
import os
import torch
from rdkit import Chem
from rdkit.Chem import AllChem, RDConfig
from enum import Enum
from torch_geometric.data import Data
from torch_geometric.datasets import MoleculeNet
sys.path.append(os.path.join(RDConfig.RDContribDir, "SA_Score"))
def mol_from_smiles(smiles):
return Chem... | 5,607 | 23.596491 | 75 | py |
GRETEL | GRETEL-main/src/explainer/meg/utils/similarity.py | from rdkit import DataStructs
from torch.nn import functional as F
from rdkit.Chem import AllChem
from src.explainer.meg.utils.fingerprints import Fingerprint
def tanimoto_similarity(fp1, fp2):
return DataStructs.TanimotoSimilarity(fp1, fp2)
def cosine_similarity(encoding_a, encoding_b):
return F.cosine_simil... | 1,688 | 38.27907 | 120 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.