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 |
|---|---|---|---|---|---|---|
bottom-up-attention | bottom-up-attention-master/lib/roi_data_layer/layer.py | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""The data layer used during training to train a Fast R-CNN network.
... | 7,856 | 37.326829 | 81 | py |
bottom-up-attention | bottom-up-attention-master/lib/roi_data_layer/minibatch.py | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Compute minibatch blobs for training a Fast R-CNN network."""
impor... | 10,006 | 41.046218 | 96 | py |
bottom-up-attention | bottom-up-attention-master/lib/fast_rcnn/test.py | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Test a Fast R-CNN network on an imdb (image database)."""
from fast... | 19,368 | 38.690574 | 123 | py |
bottom-up-attention | bottom-up-attention-master/lib/fast_rcnn/train_multi_gpu.py | # --------------------------------------------------------
# Written by Bharat Singh
# Modified version of py-R-FCN
# --------------------------------------------------------
"""Train a Fast R-CNN network."""
import caffe
from fast_rcnn.config import cfg
import roi_data_layer.roidb as rdl_roidb
from utils.timer impor... | 9,558 | 37.857724 | 107 | py |
bottom-up-attention | bottom-up-attention-master/lib/fast_rcnn/config.py | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Fast R-CNN config system.
This file specifies default config option... | 10,118 | 31.329073 | 99 | py |
bottom-up-attention | bottom-up-attention-master/lib/fast_rcnn/train.py | # --------------------------------------------------------
# Fast R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick
# --------------------------------------------------------
"""Train a Fast R-CNN network."""
import caffe
from fast_rcnn.config i... | 8,539 | 39.861244 | 92 | py |
bottom-up-attention | bottom-up-attention-master/lib/rpn/proposal_layer.py | # --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Sean Bell
# --------------------------------------------------------
import caffe
import numpy as np
import yaml
from fast_r... | 7,265 | 38.064516 | 88 | py |
bottom-up-attention | bottom-up-attention-master/lib/rpn/proposal_target_layer.py | # --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Sean Bell
# --------------------------------------------------------
import caffe
import yaml
import numpy as np
import nump... | 12,616 | 41.625 | 137 | py |
bottom-up-attention | bottom-up-attention-master/lib/rpn/anchor_target_layer.py | # --------------------------------------------------------
# Faster R-CNN
# Copyright (c) 2015 Microsoft
# Licensed under The MIT License [see LICENSE for details]
# Written by Ross Girshick and Sean Bell
# --------------------------------------------------------
import os
import caffe
import yaml
from fast_rcnn.confi... | 11,700 | 39.487889 | 95 | py |
bottom-up-attention | bottom-up-attention-master/lib/rpn/heatmap_layer.py |
import caffe
import yaml
import numpy as np
import numpy.random as npr
from fast_rcnn.config import cfg
from fast_rcnn.bbox_transform import bbox_transform
from utils.cython_bbox import bbox_overlaps
DEBUG = False
class HeatmapLayer(caffe.Layer):
"""
Takes regions of interest (rois) and outputs heatmaps.
... | 2,111 | 37.4 | 91 | py |
bottom-up-attention | bottom-up-attention-master/lib/transform/torch_image_transform_layer.py | # --------------------------------------------------------
# Fast/er R-CNN
# Licensed under The MIT License [see LICENSE for details]
# --------------------------------------------------------
""" Transform images for compatibility with models trained with
https://github.com/facebook/fb.resnet.torch.
Usage in model p... | 2,000 | 29.784615 | 72 | py |
XDF-GAN | XDF-GAN-master/run-sgan-tessellate.py | """
Script to create very large tessellated GDF
Copyright 2019 Mike Smith
Please see COPYING for licence details
"""
import matplotlib as mpl
mpl.use("Agg")
# General imports
import numpy as np
import h5py
import os
from time import time
import argparse
import astropy.io.fits as pyfits
import matplotlib.pyplot as plt... | 5,897 | 35.8625 | 166 | py |
XDF-GAN | XDF-GAN-master/run-sgan.py | """
Script to run GDF generation
Copyright 2019 Mike Smith
Please see COPYING for licence details
"""
import matplotlib as mpl
mpl.use("Agg")
# General imports
import numpy as np
import h5py
import os
from time import time
import argparse
import astropy.io.fits as pyfits
import matplotlib.pyplot as plt
from matplotli... | 6,620 | 35.379121 | 150 | py |
XDF-GAN | XDF-GAN-master/sgan.py | """
Script to train GDF-SGAN
Copyright 2019 Mike Smith
Please see COPYING for licence details
"""
import matplotlib as mpl
mpl.use("Agg")
# General imports
import numpy as np
import h5py
import os
from time import time
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import argparse
# ML specifi... | 10,761 | 39.920152 | 145 | py |
rlmeta | rlmeta-main/examples/atari/ppo/atari_ppo_rnd_model.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
import rlmeta.core.remote as remote
from rlme... | 2,889 | 35.125 | 78 | py |
rlmeta | rlmeta-main/examples/atari/ppo/atari_ppo_model.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Tuple
import torch
import torch.nn as nn
import rlmeta.core.remote as remote
from rlmeta.agents.ppo import PPOModel
fr... | 1,988 | 35.163636 | 78 | py |
rlmeta | rlmeta-main/examples/atari/ppo/atari_ppo.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import copy
import json
import logging
import time
import hydra
import torch
import torch.multiprocessing as mp
import rlmeta.envs.atari_... | 5,968 | 38.013072 | 78 | py |
rlmeta | rlmeta-main/examples/atari/ppo/atari_ppo_rnd.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import copy
import json
import logging
import time
import hydra
import torch
import torch.multiprocessing as mp
import rlmeta.envs.atari_... | 5,904 | 38.10596 | 78 | py |
rlmeta | rlmeta-main/examples/atari/dqn/atari_dqn_model.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import copy
from typing import Optional, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
import rlmeta.core.remo... | 4,918 | 34.388489 | 80 | py |
rlmeta | rlmeta-main/examples/atari/dqn/atari_apex_dqn.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import copy
import logging
import time
import hydra
import torch
import torch.multiprocessing as mp
import rlmeta.envs.atari_wrapper as a... | 6,771 | 39.071006 | 78 | py |
rlmeta | rlmeta-main/examples/tutorials/loop_example.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import asyncio
import time
from typing import Optional
import numpy as np
import torch
import torch.multiprocessing as mp
import rlmeta.... | 3,493 | 27.177419 | 80 | py |
rlmeta | rlmeta-main/examples/tutorials/remote_example.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import asyncio
import torch
import torch.multiprocessing as mp
import rlmeta.core.remote as remote
import rlmeta.utils.remote_utils as rem... | 2,053 | 22.883721 | 69 | py |
rlmeta | rlmeta-main/tests/test_utils.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unittest
import numpy as np
import torch
import rlmeta.utils.data_utils as data_utils
class TestCaseBase(unittest.TestCase):
... | 752 | 26.888889 | 65 | py |
rlmeta | rlmeta-main/tests/core/replay_buffer_test.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unittest
import torch
import rlmeta.utils.data_utils as data_utils
from rlmeta.core.replay_buffer import ReplayBuffer
from rlmeta.... | 10,383 | 42.087137 | 80 | py |
rlmeta | rlmeta-main/tests/core/remotable_test.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unittest
import numpy as np
import torch
import rlmeta.core.remote as remote
import rlmeta.utils.remote_utils as remote_utils
from ... | 1,261 | 26.434783 | 67 | py |
rlmeta | rlmeta-main/tests/core/rescalers_test.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unittest
import numpy as np
import torch
from rlmeta.core.rescalers import MomentsRescaler, RMSRescaler, SqrtRescaler
from tests.te... | 2,621 | 33.5 | 79 | py |
rlmeta | rlmeta-main/tests/utils/running_stats_test.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unittest
import torch
from rlmeta.utils.running_stats import RunningMoments, RunningRMS
from tests.test_utils import TestCaseBase
... | 4,653 | 39.824561 | 79 | py |
rlmeta | rlmeta-main/tests/data/segment_tree_test.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import pickle
import unittest
from math import prod
import numpy as np
import torch
from rlmeta.data import SumSegmentTree
from tests.tes... | 4,036 | 35.044643 | 77 | py |
rlmeta | rlmeta-main/tests/ops/discounted_return_test.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unittest
from typing import Union
import torch
import rlmeta.ops as ops
from tests.test_utils import TestCaseBase
class Discoun... | 2,278 | 29.797297 | 79 | py |
rlmeta | rlmeta-main/tests/ops/generalized_advantage_estimation_test.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import unittest
from typing import Optional, Union
import torch
import rlmeta.ops as ops
from tests.test_utils import TestCaseBase
cla... | 3,929 | 33.173913 | 74 | py |
rlmeta | rlmeta-main/rlmeta/core/loop.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import abc
import asyncio
import copy
import logging
import time
from typing import Dict, List, NoRetur... | 12,555 | 30.949109 | 113 | py |
rlmeta | rlmeta-main/rlmeta/core/server.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import annotations
import asyncio
import logging
from typing import Any, Callable, List, NoReturn, Optional, Sequence, Uni... | 5,518 | 28.994565 | 78 | py |
rlmeta | rlmeta-main/rlmeta/core/model.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import copy
import functools
import random
from enum import IntEnum
from typing import (Any, Awaitable, Callable, Dict, Optional, Sequence,... | 11,670 | 35.358255 | 80 | py |
rlmeta | rlmeta-main/rlmeta/core/types.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import numpy as np
import torch
from typing import Any, NamedTuple, Optional, Union
Tensor = Union[np.ndarray, torch.Tensor]
# NestedTens... | 2,108 | 33.57377 | 109 | py |
rlmeta | rlmeta-main/rlmeta/core/rescalers.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import abc
from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
from rlmeta.utils.running_stats import RunningMom... | 5,106 | 26.605405 | 78 | py |
rlmeta | rlmeta-main/rlmeta/core/replay_buffer.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import collections
import time
import logging
from typing import Callable, Optional, Sequence, Tuple, Union
from rich.console import Conso... | 8,167 | 33.464135 | 79 | py |
rlmeta | rlmeta-main/rlmeta/envs/gym_wrapper.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Callable, Optional
import numpy as np
import gym
from gym.wrappers.frame_stack import LazyFrames
from gym.wrappers.ste... | 2,873 | 30.582418 | 79 | py |
rlmeta | rlmeta-main/rlmeta/models/actor_critic.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Sequence, Tuple
import torch
import torch.nn as nn
import torch.nn.functional as F
from rlmeta.models.utils import MLP
... | 1,699 | 32.333333 | 76 | py |
rlmeta | rlmeta-main/rlmeta/models/utils.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Sequence
import torch
import torch.nn as nn
# The MLP class is inspired from the MLP class in DeepMind's haiku lib.
# h... | 2,810 | 32.464286 | 111 | py |
rlmeta | rlmeta-main/rlmeta/models/dqn.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Sequence
import torch
import torch.nn as nn
from rlmeta.models.utils import MLP
class DQNHead(nn.Module):
def __... | 1,306 | 29.395349 | 68 | py |
rlmeta | rlmeta-main/rlmeta/models/atari.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import torch
import torch.nn as nn
from rlmeta.models.utils import ResidualBlock
class NatureCNNBackbone(nn.Module):
def __init__(se... | 1,990 | 28.716418 | 76 | py |
rlmeta | rlmeta-main/rlmeta/agents/ppo/ppo_model.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import abc
from typing import Tuple
import torch
import torch.nn as nn
from rlmeta.core.model import RemotableModel
class PPOModel(Remo... | 1,555 | 28.358491 | 79 | py |
rlmeta | rlmeta-main/rlmeta/agents/ppo/ppo_rnd_agent.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Callable, Dict, List, Optional, Sequence
import torch
import torch.nn as nn
import rlmeta.utils.data_utils as data_util... | 10,632 | 39.276515 | 80 | py |
rlmeta | rlmeta-main/rlmeta/agents/ppo/ppo_rnd_model.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import abc
from typing import Tuple
import torch
import torch.nn as nn
from rlmeta.core.model import RemotableModel
class PPORNDModel(R... | 1,906 | 27.893939 | 78 | py |
rlmeta | rlmeta-main/rlmeta/agents/ppo/ppo_agent.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import time
from concurrent.futures import Future, ThreadPoolExecutor
from typing import Dict, Iterable, List, Optional, Sequence, Tuple, U... | 13,953 | 36.210667 | 80 | py |
rlmeta | rlmeta-main/rlmeta/agents/dqn/dqn_model.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import abc
from typing import Optional, Tuple
import torch
import torch.nn as nn
from rlmeta.core.model import RemotableModel
from rlmeta... | 2,058 | 28 | 76 | py |
rlmeta | rlmeta-main/rlmeta/agents/dqn/apex_dqn_agent.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import time
from concurrent.futures import Future, ThreadPoolExecutor
from typing import Callable, Dict, List, Optional, Sequence, Union
i... | 17,509 | 36.255319 | 80 | py |
rlmeta | rlmeta-main/rlmeta/utils/loss_utils.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, Dict, Optional
import torch
import torch.nn as nn
_NAME_TO_LOSS = {
"huber": nn.HuberLoss,
"huber_loss": n... | 872 | 26.28125 | 77 | py |
rlmeta | rlmeta-main/rlmeta/utils/optimizer_utils.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Any, Iterable, Dict, Optional, Union
import torch
_NAME_TO_OPTIMIZER = {
"adadelta": torch.optim.Adadelta,
"ada... | 990 | 29.96875 | 69 | py |
rlmeta | rlmeta-main/rlmeta/utils/random_utils.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import random
import numpy as np
import torch
def manual_seed(seed: int) -> None:
random.seed(seed)
np.random.seed(seed)
torc... | 377 | 21.235294 | 65 | py |
rlmeta | rlmeta-main/rlmeta/utils/data_utils.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import io
import os
from typing import Any, Dict, Sequence, Tuple, Union
import numpy as np
import torch
import rlmeta.utils.nested_utils... | 3,056 | 26.294643 | 76 | py |
rlmeta | rlmeta-main/rlmeta/utils/running_stats.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional, Tuple, Union
import torch
import torch.nn as nn
class RunningRMS(nn.Module):
def __init__(self,
... | 4,699 | 33.306569 | 79 | py |
rlmeta | rlmeta-main/rlmeta/data/segment_tree.py | # Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
from typing import Optional, Union
import numpy as np
import torch
from _rlmeta_extension import SumSegmentTreeFp32, SumSegmentTreeFp64
fr... | 1,899 | 26.941176 | 72 | py |
JOLLE | JOLLE-main/label_embedding_python/run_nn_ce_lshtc1.py | import torch
import numpy as np
from time import time
from sklearn.datasets import load_svmlight_files
import math
from nn_utils import *
import sys
seed = 20220510 # gonna use this integer to sample random seeds for different functions
max_int = np.iinfo(np.int32).max
rng = np.random.default_rng(seed)
train_path =... | 3,797 | 40.282609 | 170 | py |
JOLLE | JOLLE-main/label_embedding_python/run_nn_dmoz.py | import torch
import numpy as np
from time import time
from sklearn.datasets import load_svmlight_files
import math
from nn_utils import *
import sys
seed = 20230508
max_int = np.iinfo(np.int32).max
rng = np.random.default_rng(seed)
train_path = # TODO: fill the data path
val_path = # TODO: fill the data path
test_p... | 4,139 | 42.125 | 169 | py |
JOLLE | JOLLE-main/label_embedding_python/run_nn_odp.py | import torch
import numpy as np
from time import time
from sklearn.datasets import load_svmlight_files
import math
from nn_utils import *
import sys
seed = 20230508
max_int = np.iinfo(np.int32).max
rng = np.random.default_rng(seed)
train_path = # TODO: fill the data path
val_path = # TODO: fill the data path
test_p... | 4,345 | 42.029703 | 170 | py |
JOLLE | JOLLE-main/label_embedding_python/run_nn_lshtc1.py | import torch
import numpy as np
from time import time
from sklearn.datasets import load_svmlight_files
import math
from nn_utils import *
import sys
seed = 20230508
max_int = np.iinfo(np.int32).max
rng = np.random.default_rng(seed)
train_path = # TODO: fill the data path
val_path = # TODO: fill the data path
test_p... | 4,522 | 44.23 | 169 | py |
JOLLE | JOLLE-main/label_embedding_python/run_nn_sq_dmoz.py | import torch
import numpy as np
from time import time
from sklearn.datasets import load_svmlight_files
import math
from nn_utils import *
import sys
seed = 20220510 # gonna use this integer to sample random seeds for different functions
max_int = np.iinfo(np.int32).max
rng = np.random.default_rng(seed)
train_path =... | 3,764 | 39.923913 | 169 | py |
JOLLE | JOLLE-main/label_embedding_python/run_nn_ce_dmoz.py | import torch
import numpy as np
from time import time
from sklearn.datasets import load_svmlight_files
import math
from nn_utils import *
import sys
seed = 20220510 # gonna use this integer to sample random seeds for different functions
max_int = np.iinfo(np.int32).max
rng = np.random.default_rng(seed)
train_path =... | 3,793 | 40.23913 | 169 | py |
JOLLE | JOLLE-main/label_embedding_python/run_nn_sq_odp.py | import torch
import numpy as np
from time import time
from sklearn.datasets import load_svmlight_files
import math
from nn_utils import *
seed = 20230508
max_int = np.iinfo(np.int32).max
rng = np.random.default_rng(seed)
train_path = # TODO: fill the data path
val_path = # TODO: fill the data path
test_path = # TODO... | 4,026 | 40.091837 | 170 | py |
JOLLE | JOLLE-main/label_embedding_python/run_nn_sq_lshtc1.py | import torch
import numpy as np
from time import time
from sklearn.datasets import load_svmlight_files
import math
from nn_utils import *
import sys
seed = 20220510 # gonna use this integer to sample random seeds for different functions
max_int = np.iinfo(np.int32).max
rng = np.random.default_rng(seed)
train_path =... | 3,849 | 39.957447 | 169 | py |
JOLLE | JOLLE-main/label_embedding_python/run_nn_ce_odp.py | import torch
import numpy as np
from time import time
from sklearn.datasets import load_svmlight_files
import math
from nn_utils import *
seed = 20230508
max_int = np.iinfo(np.int32).max
rng = np.random.default_rng(seed)
train_path = # TODO: fill the data path
val_path = # TODO: fill the data path
test_path = # TODO... | 3,972 | 40.385417 | 170 | py |
JOLLE | JOLLE-main/label_embedding_python/nn_utils.py | import torch
from sklearn.metrics import pairwise_distances
import numpy as np
class sparse_dataset(torch.utils.data.Dataset):
def __init__(self, x, y):
self.x = x
self.y = y
self.n_features = x.shape[1]
def __len__(self):
return self.x.shape[0]
def __getitem__(sel... | 4,296 | 41.127451 | 145 | py |
apicarver | apicarver-main/testCarver/pythonCode/runEvoMaster.py | import glob
import os
import shutil
from datetime import datetime
import constants
from constants import RUN_SCHEMATHESIS_COMMAND, APPS, STATUS_SUCCESSFUL, STATUS_SKIPPED, STATUS_ERRORED, CASETTE_YAML, \
SCHEMATHESIS_OUTPUT
from utilsRun import monitorProcess, cleanup, startProcess, restartDocker, MODE
def runAl... | 6,598 | 35.865922 | 160 | py |
apicarver | apicarver-main/testCarver/pythonCode/runGeneratedTests.py | import glob
import os
from datetime import datetime, timedelta
import constants
from constants import APPS, STATUS_SUCCESSFUL, STATUS_ERRORED
from utilsRun import restartDocker, startProcess, monitorProcess, getDockerName, cleanup, MODE, exportJson
# BASE_COMMAND_HYBRID = ['sh', 'runTests.sh']
BASE_COMMAND = ['sh', '... | 6,899 | 29 | 137 | py |
apicarver | apicarver-main/testCarver/pythonCode/utilsRun.py | import csv
import json
import os
import subprocess
from datetime import datetime
from enum import Enum
from subprocess import check_call, CalledProcessError, Popen
from time import sleep
import psutil
from constants import DOCKER_LOCATION, STATUS_SUCCESSFUL
def getDockerName(appName):
return appName
def restartD... | 4,316 | 22.983333 | 113 | py |
apicarver | apicarver-main/testCarver/pythonCode/runSchemathesis.py | import glob
import os
import shutil
from datetime import datetime
import constants
from constants import RUN_SCHEMATHESIS_COMMAND, APPS, STATUS_SUCCESSFUL, STATUS_SKIPPED, STATUS_ERRORED, CASETTE_YAML, \
SCHEMATHESIS_OUTPUT
from utilsRun import monitorProcess, cleanup, startProcess, restartDocker, MODE
def runAl... | 6,970 | 39.063218 | 134 | py |
apicarver | apicarver-main/testCarver/pythonCode/rq1_executionTime.py | import glob
import os.path
from datetime import datetime
import utilsRun
from constants import APPS
from coverageStats import getCovFiles
from runCarver import getExistingCarverRun
from runGeneratedTests import getCrawlsToAnalyze, getExistingCrawl
from utilsRun import importJson
def findAllOutputs(ALL_CRAWLS="../cra... | 3,289 | 37.255814 | 142 | py |
apicarver | apicarver-main/testCarver/pythonCode/runCarver.py | import os
import shutil
from datetime import datetime
# from globalNames import FILTER, THRESHOLD_SETS, DB_SETS, APPS, isDockerized, DOCKER_LOCATION, isNd3App, getHostNames, \
# ALGOS, getDockerName, getDockerList, getURLList
import glob
from constants import APPS, RUN_CARVER_COMMAND, STATUS_SUCCESSFUL, STATUS_SKIPPED... | 4,439 | 29.62069 | 121 | py |
longitudinalCOVID | longitudinalCOVID-master/main.py | import argparse
import os
import random
from collections import defaultdict
from copy import copy
import numpy as np
import torch
import data_loader as module_data_loader
import dataset as module_dataset
import model as module_arch
import model.utils.loss as module_loss
import model.utils.metric as module_metric
impo... | 6,108 | 41.72028 | 123 | py |
longitudinalCOVID | longitudinalCOVID-master/majority_voting.py | import argparse
import os
import nibabel
import numpy as np
import torch
from scipy.ndimage import rotate
from tqdm import tqdm
import data_loader as module_data_loader
import dataset as module_dataset
import model as module_arch
import model.utils.metric as module_metric
from dataset.DatasetStatic import Phase
from ... | 7,995 | 41.084211 | 115 | py |
longitudinalCOVID | longitudinalCOVID-master/trainer/LongitudinalWithProgressionTrainer.py | import numpy
from logger import Mode
from trainer.Trainer import Trainer
from utils.illustration_util import log_visualizations
import torch.nn.functional as F
import torch
class LongitudinalWithProgressionTrainer(Trainer):
"""
Trainer class for training with original loss + difference map loss + reverse ord... | 5,986 | 51.982301 | 140 | py |
longitudinalCOVID | longitudinalCOVID-master/trainer/StaticTrainer.py | from logger import Mode
from trainer.Trainer import Trainer
from utils.illustration_util import log_visualizations
import torch.nn.functional as F
class StaticTrainer(Trainer):
"""
Trainer class for base training
"""
def __init__(self, model, loss, metric_ftns, optimizer, config, data_loader, fold=N... | 5,253 | 51.54 | 141 | py |
longitudinalCOVID | longitudinalCOVID-master/trainer/LongitudinalTrainer.py |
import numpy
from logger import Mode
from trainer.Trainer import Trainer
from utils.illustration_util import log_visualizations
import torch.nn.functional as F
import torch
class LongitudinalTrainer(Trainer):
"""
Trainer class
"""
def __init__(self, model, loss, metric_ftns, optimizer, config, data... | 6,063 | 47.512 | 140 | py |
longitudinalCOVID | longitudinalCOVID-master/trainer/Trainer.py | from abc import abstractmethod
import numpy as np
import torch
from base import BaseTrainer
from logger import Mode
from utils import MetricTracker
class Trainer(BaseTrainer):
"""
Trainer class
"""
def __init__(self, model, loss, metric_ftns, optimizer, config, data_loader, fold=None,
... | 5,947 | 40.594406 | 132 | py |
longitudinalCOVID | longitudinalCOVID-master/data_loader/Dataloader.py | from torch.utils.data import DataLoader, RandomSampler, SequentialSampler, WeightedRandomSampler
from torch.utils.data.dataloader import default_collate
import numpy as np
class Dataloader(DataLoader):
"""
data loading -- uncomment the commented lines for reverse weight sampling the classes
"""
def __... | 1,242 | 34.514286 | 125 | py |
longitudinalCOVID | longitudinalCOVID-master/dataset/rigid_and_deformable_registration.py | from pathlib import Path
import SimpleITK as sitk
import numpy as np
import sys
import torch
import nibabel as nib
from skimage.transform import resize
def iteration_callback(filter):
global itr
print("deformable iter:", itr, "loss:", filter.GetMetricValue(), flush=True)
itr += 1
def save(filter, fixed... | 6,550 | 45.792857 | 118 | py |
longitudinalCOVID | longitudinalCOVID-master/dataset/DatasetStatic.py | import os
import sys
import h5py
import numpy as np
import torch
import torch.nn.functional as F
from PIL import Image
from matplotlib import cm
from skimage.transform import resize
from torch.utils.data import Dataset
from pathlib import Path
from skimage import feature
from torchvision.transforms import transforms
... | 4,367 | 43.571429 | 165 | py |
longitudinalCOVID | longitudinalCOVID-master/dataset/DatasetLongitudinal.py | import os
import h5py
import numpy as np
import torch
import torch.nn.functional as F
from PIL import Image
from skimage import feature
from skimage.transform import resize
from torch.utils.data import Dataset
from torchvision import transforms
from dataset.dataset_utils import Phase, Modalities, Mode, retrieve_data_d... | 4,962 | 46.721154 | 157 | py |
longitudinalCOVID | longitudinalCOVID-master/dataset/dynamic/util.py | from pathlib import Path
import yaml
import numpy as np
from sklearn.model_selection import train_test_split
import pandas as pd
import hashlib
import torch
def load_config_yaml(path):
"""loads a yaml config from file and returns a dict"""
path = Path(path)
with open(path) as file:
cfg = yaml.full... | 7,244 | 32.082192 | 217 | py |
longitudinalCOVID | longitudinalCOVID-master/logger/visualization.py | import importlib
from datetime import datetime
from enum import Enum
class Mode(Enum):
TRAIN = 'Train'
VAL = 'Val'
class TensorboardWriter():
def __init__(self, log_dir, logger, enabled):
self.writer = None
self.selected_module = ""
if enabled:
log_dir = str(log_dir)... | 3,020 | 36.296296 | 125 | py |
longitudinalCOVID | longitudinalCOVID-master/base/base_model.py | from abc import abstractmethod
import numpy as np
import torch.nn as nn
class BaseModel(nn.Module):
"""
Base class for all models
"""
@abstractmethod
def forward(self, *inputs):
"""
Forward pass logic
:return: Model output
"""
raise NotImplementedError
... | 650 | 22.25 | 79 | py |
longitudinalCOVID | longitudinalCOVID-master/base/base_trainer.py | from abc import abstractmethod
import torch
from numpy import inf
from logger import TensorboardWriter
class BaseTrainer:
"""
Base class for all trainers
"""
def __init__(self, model, loss, metric_ftns, optimizer, config, fold=None):
self.config = config
self.logger = config.get_log... | 7,505 | 39.354839 | 133 | py |
longitudinalCOVID | longitudinalCOVID-master/base/base_data_loader.py | import numpy as np
from torch.utils.data import DataLoader
from torch.utils.data.dataloader import default_collate
from torch.utils.data.sampler import SubsetRandomSampler
class BaseDataLoader(DataLoader):
"""
Base class for all data loaders
"""
def __init__(self, dataset, batch_size, shuffle, valida... | 1,971 | 30.301587 | 112 | py |
longitudinalCOVID | longitudinalCOVID-master/utils/illustration_util.py | import cv2
import numpy as np
import torch
from torchvision.transforms import transforms
from torchvision.utils import make_grid
from PIL import Image, ImageDraw
def warp_flow(img, flow):
h, w = flow.shape[:2]
flow = -flow
flow[:, :, 0] += np.arange(w)
flow[:, :, 1] += np.arange(h)[:, np.newaxis]
... | 7,893 | 40.547368 | 158 | py |
longitudinalCOVID | longitudinalCOVID-master/model/LongitudinalFCDenseNet.py | from base import BaseModel
from model.FCDenseNet import FCDenseNetEncoder, FCDenseNetDecoder
from model.utils.layers import *
class LongitudinalFCDenseNet(BaseModel):
def __init__(self,
in_channels=1, down_blocks=(4, 4, 4, 4, 4),
up_blocks=(4, 4, 4, 4, 4), bottleneck_layers=4,
... | 1,858 | 45.475 | 128 | py |
longitudinalCOVID | longitudinalCOVID-master/model/LateLongitudinalFCDenseNet.py | from base import BaseModel
from model.FCDenseNet import FCDenseNetEncoder, FCDenseNetDecoder
from model.utils.layers import *
class LateLongitudinalFCDenseNet(BaseModel):
def __init__(self,
in_channels=1, down_blocks=(4, 4, 4, 4, 4),
up_blocks=(4, 4, 4, 4, 4), bottleneck_layers=4... | 1,423 | 38.555556 | 128 | py |
longitudinalCOVID | longitudinalCOVID-master/model/utils/metric_utils.py | import numpy as np
import torch
def asymmetric_loss(beta, output, target):
g = flatten(target)
p = flatten(output)
pg = (p * g).sum(-1)
beta_sq = beta ** 2
a = beta_sq / (1 + beta_sq)
b = 1 / (1 + beta_sq)
g_p = ((1 - p) * g).sum(-1)
p_g = (p * (1 - g)).sum(-1)
loss = (1. + pg) / (... | 1,646 | 32.612245 | 70 | py |
longitudinalCOVID | longitudinalCOVID-master/model/utils/loss.py | import torch
import torch.nn.functional as F
from model.utils import metric_utils
import numpy as np
def inf(*args):
return torch.as_tensor(float("Inf"))
def gradient_loss(s):
dy = torch.abs(s[:, :, 1:, :] - s[:, :, :-1, :]) ** 2
dx = torch.abs(s[:, :, :, 1:] - s[:, :, :, :-1]) ** 2
return (torch.me... | 1,817 | 26.969231 | 108 | py |
longitudinalCOVID | longitudinalCOVID-master/model/utils/layers.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class SpatialTransformer(nn.Module):
def __init__(self, size, mode='bilinear'):
super(SpatialTransformer, self).__init__()
vectors = [torch.arange(0, s) for s in size]
grid = torch.unsqueeze(torch.stack(torch.meshgrid(vect... | 3,420 | 32.871287 | 142 | py |
longitudinalCOVID | longitudinalCOVID-master/model/utils/metric.py | import numpy as np
import torch
from sklearn.metrics import f1_score, precision_score, recall_score, roc_curve
from medpy import metric
from model.utils import metric_utils
def precision(output, target):
with torch.no_grad():
target = metric_utils.flatten(target).cpu().detach().float()
output = me... | 5,769 | 30.703297 | 99 | py |
RAML | RAML-master/incremental/main.py | from tqdm import tqdm
import network
import utils
import os
import random
import argparse
import numpy as np
import torch.nn.functional as F
from torch.utils import data
from datasets import VOCSegmentation, Cityscapes, cityscapes
from utils import ext_transforms as et
from metrics import StreamSegMetrics
import torc... | 28,621 | 42.170437 | 171 | py |
RAML | RAML-master/incremental/main_metric.py | from tqdm import tqdm
import network
import utils
import os
import random
import argparse
import numpy as np
import torch.nn.functional as F
from torch.utils import data
from datasets import VOCSegmentation, Cityscapes, cityscapes, Cityscapes_Novel
from utils import ext_transforms as et
from metrics import StreamSegMe... | 40,855 | 43.408696 | 152 | py |
RAML | RAML-master/incremental/test_metric.py | from datasets.cityscapes_novel import Cityscapes_Novel
from tqdm import tqdm
import network
import utils
import os
import random
import argparse
import numpy as np
import torch.nn.functional as F
from torch.utils import data
from datasets import VOCSegmentation, Cityscapes, Cityscapes_Novel
from utils import ext_trans... | 31,049 | 46.40458 | 153 | py |
RAML | RAML-master/incremental/datasets/voc.py | import os
import sys
import tarfile
import collections
import torch.utils.data as data
import shutil
import numpy as np
from PIL import Image
from torchvision.datasets.utils import download_url, check_integrity
DATASET_YEAR_DICT = {
'2012': {
'url': 'http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrain... | 6,061 | 36.190184 | 128 | py |
RAML | RAML-master/incremental/datasets/cityscapes.py | import json
import os
from collections import namedtuple
from matplotlib import set_loglevel
import torch
import torch.utils.data as data
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from torchvision import transforms
import cv2
class Cityscapes(data.Dataset):
"""Cityscapes <http://ww... | 11,663 | 51.540541 | 168 | py |
RAML | RAML-master/incremental/datasets/cityscapes_novel.py | import json
import os
from collections import namedtuple
from matplotlib import set_loglevel
import torch
import torch.utils.data as data
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from torchvision import transforms
class Cityscapes_Novel(data.Dataset):
"""Cityscapes <http://www.ci... | 8,742 | 48.39548 | 168 | py |
RAML | RAML-master/incremental/datasets/.ipynb_checkpoints/cityscapes-checkpoint.py | import json
import os
from collections import namedtuple
from matplotlib import set_loglevel
import torch
import torch.utils.data as data
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from torchvision import transforms
import cv2
class Cityscapes(data.Dataset):
"""Cityscapes <http://ww... | 11,663 | 51.540541 | 168 | py |
RAML | RAML-master/incremental/datasets/.ipynb_checkpoints/cityscapes_novel-checkpoint.py | import json
import os
from collections import namedtuple
from matplotlib import set_loglevel
import torch
import torch.utils.data as data
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from torchvision import transforms
class Cityscapes_Novel(data.Dataset):
"""Cityscapes <http://www.ci... | 8,742 | 48.39548 | 168 | py |
RAML | RAML-master/incremental/network/_deeplab.py | import torch
from torch import nn
from torch.nn import functional as F
from .utils import _SimpleSegmentationModel, _SimpleSegmentationModel_embedding, _SimpleSegmentationModel_embedding_self_distillation,_SimpleSegmentationModel_Metric
__all__ = ["DeepLabV3"]
class DeepLabV3(_SimpleSegmentationModel):
"""
... | 8,740 | 39.281106 | 165 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.