repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
cppflow | cppflow-master/examples/multi_input_output/create_model.py | #!/usr/bin/env python
"""
Example for a multiple inputs and outputs functionality.
"""
# MIT License
#
# Copyright (c) 2020 Sergio Izquierdo
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Soft... | 2,144 | 36.631579 | 79 | py |
cppflow | cppflow-master/docs/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 2,455 | 34.085714 | 89 | py |
cppflow | cppflow-master/include/cppflow/ops_generator/generator.py | #!/usr/bin/env python
"""
Generates the raw_ops.h cpp code.
"""
# MIT License
#
# Copyright (c) 2020 Sergio Izquierdo
# Copyright (c) 2020 Jiannan Liu
# Copyright (c) 2022 Alfredo Rodriguez
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentat... | 14,554 | 36.707254 | 172 | py |
BOExplain | BOExplain-main/docs/source/conf.py | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... | 2,173 | 32.96875 | 89 | py |
BOExplain | BOExplain-main/boexplain/__init__.py | from .files import fmin, fmax
__all__ = ["fmin", "fmax"] | 57 | 18.333333 | 29 | py |
BOExplain | BOExplain-main/boexplain/optuna/setup.py | import os
import sys
import pkg_resources
from setuptools import find_packages
from setuptools import setup
from typing import Dict
from typing import List
from typing import Optional
def get_version() -> str:
version_filepath = os.path.join(os.path.dirname(__file__), "optuna", "version.py")
with open(vers... | 5,283 | 28.032967 | 99 | py |
BOExplain | BOExplain-main/boexplain/optuna/__init__.py | 0 | 0 | 0 | py | |
BOExplain | BOExplain-main/boexplain/optuna/optuna/distributions.py | import abc
import decimal
import json
import warnings
# from optuna import logging
from . import logging
class BaseDistribution(object, metaclass=abc.ABCMeta):
"""Base class for distributions.
Note that distribution classes are not supposed to be called by library users.
They are used by :class:`~optuna... | 14,890 | 29.26626 | 99 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/progress_bar.py | import logging
from typing import Any
from typing import Optional
from tqdm.auto import tqdm
# from optuna import logging as optuna_logging
from . import logging as optuna_logging
_tqdm_handler = None # type: Optional[_TqdmLoggingHandler]
# Reference: https://gist.github.com/hvy/8b80c2cedf02b15c24f85d1fa17ebe02
c... | 2,698 | 32.320988 | 96 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/exceptions.py | class OptunaError(Exception):
"""Base class for Optuna specific errors."""
pass
class TrialPruned(OptunaError):
"""Exception for pruned trials.
This error tells a trainer that the current :class:`~optuna.trial.Trial` was pruned. It is
supposed to be raised after :func:`optuna.trial.Trial.should_... | 2,423 | 25.637363 | 97 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/structs.py | import warnings
from optuna import _study_direction
from optuna import exceptions
from optuna import logging
from optuna import trial
_logger = logging.get_logger(__name__)
_message = (
"`structs` is deprecated. Classes have moved to the following modules. "
"`structs.StudyDirection`->`study.StudyDirection`... | 7,962 | 31.904959 | 99 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/logging.py | import logging
from logging import CRITICAL # NOQA
from logging import DEBUG # NOQA
from logging import ERROR # NOQA
from logging import FATAL # NOQA
from logging import INFO # NOQA
from logging import WARN # NOQA
from logging import WARNING # NOQA
import threading
import colorlog
_lock = threading.Lock()
_def... | 6,076 | 27.134259 | 96 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/study.py | import collections
import datetime
import gc
import math
import threading
import warnings
import numpy as np
import pandas as pd # NOQA
# from optuna._study_direction import StudyDirection
# from optuna import exceptions
# from optuna import logging
# from optuna import progress_bar as pbar_module
# from optuna im... | 22,675 | 34.102167 | 108 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/__init__.py | import importlib
import types
from typing import Any
# from optuna import distributions # NOQA
# from optuna import exceptions # NOQA
# from optuna import logging # NOQA
# from optuna import pruners # NOQA
# from optuna import samplers # NOQA
# from optuna import storages # NOQA
# from optuna import study # NOQ... | 819 | 29.37037 | 42 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/_study_direction.py | import enum
class StudyDirection(enum.Enum):
"""Direction of a :class:`~optuna.study.Study`.
Attributes:
NOT_SET:
Direction has not been set.
MINIMIZE:
:class:`~optuna.study.Study` minimizes the objective function.
MAXIMIZE:
:class:`~optuna.study.St... | 418 | 21.052632 | 74 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/storages/base.py | import abc
import copy
from typing import Any
from typing import Dict
from typing import List
from typing import Optional
# from optuna import study
# from optuna.trial import TrialState
from .. import study
from ..trial import TrialState
DEFAULT_STUDY_NAME_PREFIX = "no-name-"
class BaseStorage(object, metaclass=ab... | 20,677 | 30.377845 | 99 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/storages/in_memory.py | import copy
from datetime import datetime
import threading
import uuid
# from optuna import distributions # NOQA
# from optuna.exceptions import DuplicatedStudyError
# from optuna.storages import base
# from optuna.storages.base import DEFAULT_STUDY_NAME_PREFIX
# from optuna.study import StudyDirection
# from optuna.... | 14,933 | 33.09589 | 95 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/storages/__init__.py | from typing import Union # NOQA
# from optuna.storages.base import BaseStorage
# from optuna.storages.in_memory import InMemoryStorage
from .base import BaseStorage
from .in_memory import InMemoryStorage
def get_storage(storage):
# type: (Union[None, str, BaseStorage]) -> BaseStorage
if storage is None:
... | 382 | 26.357143 | 58 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/trial/_fixed.py | import datetime
# from optuna import distributions
# from optuna.trial._base import BaseTrial
# from optuna.trial._util import _adjust_discrete_uniform_high
from .. import distributions
from ._base import BaseTrial
from ._util import _adjust_discrete_uniform_high
class FixedTrial(BaseTrial):
"""A trial class whi... | 6,151 | 31.041667 | 99 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/trial/_frozen.py | import datetime
import warnings
# from optuna import distributions
# from optuna import logging
# from optuna.trial._state import TrialState
from .. import distributions
from .. import logging
from ._state import TrialState
_logger = logging.get_logger(__name__)
class FrozenTrial(object):
"""Status and results ... | 7,018 | 31.050228 | 99 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/trial/_util.py | import decimal
# from optuna import logging
from .. import logging
_logger = logging.get_logger(__name__)
def _adjust_discrete_uniform_high(name, low, high, q):
# type: (str, float, float, float) -> float
d_high = decimal.Decimal(str(high))
d_low = decimal.Decimal(str(low))
d_q = decimal.Decimal(st... | 631 | 23.307692 | 74 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/trial/_base.py | import abc
import datetime
# from optuna import distributions
# from optuna import logging
from .. import distributions
from .. import logging
_logger = logging.get_logger(__name__)
class BaseTrial(object, metaclass=abc.ABCMeta):
"""Base class for trials.
Note that this class is not supposed to be directly... | 2,836 | 22.840336 | 96 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/trial/__init__.py | # from optuna.trial._base import BaseTrial # NOQA
# from optuna.trial._fixed import FixedTrial # NOQA
# from optuna.trial._frozen import FrozenTrial # NOQA
# from optuna.trial._state import TrialState # NOQA
# from optuna.trial._trial import Trial # NOQA
from ._base import BaseTrial # NOQA
from ._fixed import Fix... | 449 | 44 | 54 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/trial/_state.py | import enum
class TrialState(enum.Enum):
"""State of a :class:`~optuna.trial.Trial`.
Attributes:
RUNNING:
The :class:`~optuna.trial.Trial` is running.
COMPLETE:
The :class:`~optuna.trial.Trial` has been finished without any error.
PRUNED:
The :class... | 805 | 22.705882 | 81 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/trial/_trial.py | import datetime
import warnings
import numpy as np
from operator import itemgetter
from itertools import chain, combinations, product
# from optuna import distributions
# from optuna.distributions import CategoricalDistribution
# from optuna.distributions import DiscreteUniformDistribution
# from optuna.distributions... | 67,255 | 40.210784 | 176 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/pruners/base.py | import abc
class BasePruner(object, metaclass=abc.ABCMeta):
"""Base class for pruners."""
@abc.abstractmethod
def prune(self, study, trial):
# type: (Study, FrozenTrial) -> bool
"""Judge whether the trial should be pruned based on the reported values.
Note that this method is not... | 846 | 30.37037 | 93 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/pruners/nop.py | # from optuna.pruners import BasePruner
from . import BasePruner
class NopPruner(BasePruner):
"""Pruner which never prunes trials.
Example:
.. testsetup::
import numpy as np
from sklearn.model_selection import train_test_split
np.random.seed(seed=0)
... | 1,632 | 30.403846 | 99 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/pruners/__init__.py | # import optuna
# from optuna.pruners.base import BasePruner
# from optuna.pruners.nop import NopPruner
from ... import optuna
from .base import BasePruner
from .nop import NopPruner
def _filter_study(
study: "optuna.study.Study", trial: "optuna.trial.FrozenTrial"
) -> "optuna.study.Study":
return study
| 315 | 23.307692 | 66 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/samplers/base.py | import abc
class BaseSampler(object, metaclass=abc.ABCMeta):
"""Base class for samplers.
Optuna combines two types of sampling strategies, which are called *relative sampling* and
*independent sampling*.
*The relative sampling* determines values of multiple parameters simultaneously so that
samp... | 5,487 | 39.651852 | 98 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/samplers/_search_space.py | from collections import OrderedDict
import copy
from typing import Dict
from typing import Optional
# import optuna
# from optuna.distributions import BaseDistribution
# from optuna.study import BaseStudy
from ... import optuna
from ..distributions import BaseDistribution
from ..study import BaseStudy
class Intersec... | 4,886 | 38.731707 | 99 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/samplers/random.py | import numpy
# from optuna import distributions
# from optuna.samplers.base import BaseSampler
from .. import distributions
from ..samplers.base import BaseSampler
class RandomSampler(BaseSampler):
"""Sampler using random sampling.
This sampler is based on *independent sampling*.
See also :class:`~optuna... | 3,847 | 40.376344 | 94 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/samplers/__init__.py | # from optuna.samplers._search_space import intersection_search_space # NOQA
# from optuna.samplers._search_space import IntersectionSearchSpace # NOQA
# from optuna.samplers.base import BaseSampler # NOQA
# from optuna.samplers.random import RandomSampler # NOQA
# from optuna.samplers.tpe import TPESampler # NOQA... | 556 | 54.7 | 77 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/samplers/tpe/parzen_estimator.py | from typing import Callable
from typing import NamedTuple
from typing import Optional
import numpy
from numpy import ndarray
EPS = 1e-12
class _ParzenEstimatorParameters(
NamedTuple(
"_ParzenEstimatorParameters",
[
("consider_prior", bool),
("prior_weight", Optional[float... | 6,249 | 38.556962 | 125 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/samplers/tpe/sampler.py | import math
import numpy as np
import scipy.special
from scipy.stats import truncnorm
# from optuna import distributions
# from optuna.samplers import base
# from optuna.samplers import random
# from optuna.samplers.tpe.parzen_estimator import _ParzenEstimator
# from optuna.samplers.tpe.parzen_estimator import _Parze... | 29,882 | 39.99177 | 124 | py |
BOExplain | BOExplain-main/boexplain/optuna/optuna/samplers/tpe/__init__.py | # from optuna.samplers.tpe.sampler import TPESampler # NOQA
from .sampler import TPESampler # NOQA | 100 | 49.5 | 60 | py |
BOExplain | BOExplain-main/boexplain/files/stats.py | from typing import Any
import re
import random
import numpy as np
import pandas as pd
import altair as alt
alt.data_transformers.disable_max_rows()
from json import dumps
from numpyencoder import NumpyEncoder
class Experiment:
experiments = dict()
n_exp = 0
def __init__(
self,
num_cols,... | 10,326 | 31.784127 | 181 | py |
BOExplain | BOExplain-main/boexplain/files/__init__.py | from .search import fmin, fmax
__all__ = ["fmin", "fmax"] | 58 | 18.666667 | 30 | py |
BOExplain | BOExplain-main/boexplain/files/search.py | import time
from pandas.api.types import is_numeric_dtype
from .cat_xform import individual_contribution
from .tpe_wrapper import TpeBo
from .stats import Experiment, Stats
CAT_ALG_MAP = {
"individual_contribution": "individual_contribution_warm_start_top1",
"categorical": "categorical",
"categorical_war... | 8,685 | 24.698225 | 84 | py |
BOExplain | BOExplain-main/boexplain/files/cat_xform.py | import pandas as pd
import numpy as np
def individual_contribution(df, objective, cat_cols, **kwargs):
# dictionary of dictionaries, one dictionary for each column
# dictinary keys are the categorical values and the values are the individual contribution
# for each value in the column, compute the individ... | 669 | 36.222222 | 94 | py |
BOExplain | BOExplain-main/boexplain/files/tpe_wrapper.py | import time
from itertools import product
import numpy as np
from ..optuna.optuna.samplers import tpe
from ..optuna.optuna.study import create_study
class TpeBo(object):
def __init__(
self,
df,
objective,
num_cols,
cat_cols,
direction,
k,
cat_alg,
... | 32,427 | 43.728276 | 103 | py |
SPMC_VideoSR | SPMC_VideoSR-master/main_videosr_deploy_2x3f.py | import os
import time
import glob
import numpy as np
import tensorflow as tf
import tensorflow.contrib.slim as slim
from tensorflow.python.ops import control_flow_ops
import scipy.misc
import random
import subprocess
from datetime import datetime
from math import ceil
# from modules import BasicConvLSTMCell
# from mod... | 5,347 | 41.444444 | 206 | py |
SPMC_VideoSR | SPMC_VideoSR-master/main_videosr_deploy_4x3f.py | import os
import time
import glob
import numpy as np
import tensorflow as tf
import tensorflow.contrib.slim as slim
from tensorflow.python.ops import control_flow_ops
import scipy.misc
import random
import subprocess
from datetime import datetime
from math import ceil
# from modules import BasicConvLSTMCell
# from mod... | 4,510 | 39.276786 | 206 | py |
SPMC_VideoSR | SPMC_VideoSR-master/modules/utils.py |
import tensorflow as tf
def weight_from_caffe(caffenet):
def func(shape, dtype):
sc = tf.get_variable_scope()
name = sc.name.split('/')[-1]
print 'init: ', name, shape, caffenet.params[name][0].data.shape
return tf.transpose(caffenet.params[name][0].data, perm=[2 ,3 ,1 ,0])
ret... | 527 | 25.4 | 77 | py |
SPMC_VideoSR | SPMC_VideoSR-master/modules/videosr_ops_lite.py | import numpy as np
import tensorflow as tf
from tensorflow.python.ops import control_flow_ops
slim = tf.contrib.slim
def im2uint8(x):
if x.__class__ == tf.Tensor:
return tf.cast(tf.clip_by_value(x, 0.0, 1.0) * 255.0, tf.uint8)
else:
t = np.clip(x, 0.0, 1.0) * 255.0
return t.astype(np.... | 5,349 | 37.768116 | 121 | py |
SPMC_VideoSR | SPMC_VideoSR-master/modules/__init__.py | # -*- coding: utf-8 -*-
__all__=['BasicConvLSTMCell','flowTools','model_easyflow','model_flownet','SSIM_Index','utils','videos_ops']
| 135 | 26.2 | 108 | py |
CLOSURE | CLOSURE-master/setup.py | from setuptools import setup
setup(
name="nmn-iwp",
version="0.1",
keywords="",
packages=["vr", "vr.models"]
)
| 128 | 13.333333 | 32 | py |
CLOSURE | CLOSURE-master/vr/plotting.py | import os
import json
from matplotlib import pyplot
import pandas
import scipy.stats as stats
import logging
logger = logging.getLogger(__name__)
def load_log(root, file_, data_train, data_val, args, parts):
slurmid = file_[:-8]
path = os.path.join(root, file_)
log = json.load(open(path))
args[ro... | 5,907 | 42.441176 | 114 | py |
CLOSURE | CLOSURE-master/vr/programs.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 5,119 | 31.201258 | 138 | py |
CLOSURE | CLOSURE-master/vr/utils.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 6,077 | 32.58011 | 138 | py |
CLOSURE | CLOSURE-master/vr/data.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 9,208 | 37.85654 | 138 | py |
CLOSURE | CLOSURE-master/vr/__init__.py | # This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://github.com/rizar/CLOSURE/... | 329 | 54 | 138 | py |
CLOSURE | CLOSURE-master/vr/preprocess.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 3,040 | 29.108911 | 138 | py |
CLOSURE | CLOSURE-master/vr/models/seq2seq_att.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 8,941 | 38.566372 | 138 | py |
CLOSURE | CLOSURE-master/vr/models/baselines.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 8,657 | 34.052632 | 138 | py |
CLOSURE | CLOSURE-master/vr/models/filmed_net.py | #!/usr/bin/env python3
import math
import pprint
from termcolor import colored
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.models
from vr.models.layers import init_modules, GlobalAveragePool, Flatten
from vr.models.layers import build_class... | 19,181 | 42.202703 | 133 | py |
CLOSURE | CLOSURE-master/vr/models/seq2seq.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 7,657 | 38.885417 | 138 | py |
CLOSURE | CLOSURE-master/vr/models/layers.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 9,120 | 36.228571 | 138 | py |
CLOSURE | CLOSURE-master/vr/models/maced_net.py | #!/usr/bin/env python3
import numpy as np
import math
import pprint
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
import torchvision.models
import math
from torch.nn.init import kaiming_normal, kaiming_uniform, xavier_uniform, xavier_normal, constant
from vr.mo... | 21,616 | 37.809695 | 119 | py |
CLOSURE | CLOSURE-master/vr/models/convlstm.py | #!/usr/bin/env python3
import torch
import torch.nn as nn
from torch.autograd import Variable
from vr.models.layers import (build_classifier,
build_stem,
init_modules)
class ConvLSTM(nn.Module):
def __init__(self,
vocab,
... | 2,782 | 35.142857 | 73 | py |
CLOSURE | CLOSURE-master/vr/models/__init__.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 710 | 40.823529 | 138 | py |
CLOSURE | CLOSURE-master/vr/models/film_gen.py | #!/usr/bin/env python3
import torch
import torch.cuda
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
from vr.models.layers import init_modules
from torch.nn.init import uniform_, xavier_uniform_, consta... | 13,957 | 39.34104 | 131 | py |
CLOSURE | CLOSURE-master/vr/models/module_net.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 15,132 | 40.803867 | 138 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/parser.py | import torch
import torch.nn as nn
from torch.autograd import Variable
from . import create_seq2seq_net, TrainOptions
class Seq2seqParser(nn.Module):
"""Model interface for seq2seq parser"""
def __init__(self, vocab):
super().__init__()
self.opt = TrainOptions().parse()
self.vocab = ... | 4,059 | 37.301887 | 106 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/base_rnn.py | import torch.nn as nn
class BaseRNN(nn.Module):
"""Base RNN module"""
def __init__(self, vocab_size, max_len, hidden_size, input_dropout_p,
dropout_p, n_layers, rnn_cell):
super(BaseRNN, self).__init__()
self.vocab_size = vocab_size
self.max_len = max_le... | 829 | 28.642857 | 74 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/train_options.py | from .base_options import BaseOptions
class TrainOptions(BaseOptions):
"""Train option class"""
def __init__(self):
super(TrainOptions, self).__init__()
# Data
self.parser.add_argument('--max_train_samples', default=None, type=int, help='max number of training samples')
self.p... | 3,556 | 79.840909 | 136 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/base_options.py | import os
import argparse
import numpy as np
import torch
class BaseOptions():
"""Base option class"""
def __init__(self):
self.parser = argparse.ArgumentParser()
self.parser.add_argument('--run_dir', default='_scratch/test_run', type=str, help='experiment directory')
self.parser.add... | 3,439 | 45.486486 | 125 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/seq2seq.py | import torch
import torch.nn as nn
class Seq2seq(nn.Module):
"""Seq2seq model module
To do: add docstring to methods
"""
def __init__(self, encoder, decoder):
super(Seq2seq, self).__init__()
self.encoder = encoder
self.decoder = decoder
def forward(self, x, y, input_lengt... | 1,700 | 42.615385 | 131 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/utils.py | import os
import json
import numpy as np
import torch
def mkdirs(paths):
if isinstance(paths, list):
for path in paths:
if not os.path.exists(path):
os.makedirs(path)
else:
if not os.path.exists(paths):
os.makedirs(paths)
def invert_dict(d):
return {... | 2,041 | 31.935484 | 85 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/encoder.py | import torch.nn as nn
from .base_rnn import BaseRNN
class Encoder(BaseRNN):
"""Encoder RNN module"""
def __init__(self, vocab_size, max_len, word_vec_dim, hidden_size, n_layers,
input_dropout_p=0., dropout_p=0., bidirectional=False, rnn_cell='lstm',
variable_lengths=False, w... | 1,726 | 44.447368 | 119 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/clevr_executor.py | import torch
import random
import json
CLEVR_COLORS = ['blue', 'brown', 'cyan', 'gray', 'green', 'purple', 'red', 'yellow']
CLEVR_MATERIALS = ['rubber', 'metal']
CLEVR_SHAPES = ['cube', 'cylinder', 'sphere']
CLEVR_SIZES = ['large', 'small']
CLEVR_ANSWER_CANDIDATES = {
'count': ['0', '1', '2', '3', '4', '5', '6'... | 15,787 | 32.378436 | 125 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/decoder.py | import numpy as np
import torch
import torch.nn as nn
from torch.autograd import Variable
import torch.nn.functional as F
from .base_rnn import BaseRNN
from .attention import Attention
def logical_or(x, y):
return (x + y).clamp_(0, 1)
def logical_not(x):
return x == 0
class Decoder(BaseRNN):
"""Decod... | 4,566 | 39.061404 | 132 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/__init__.py | from .encoder import Encoder
from .decoder import Decoder
from .seq2seq import Seq2seq
from .train_options import TrainOptions
def create_seq2seq_net(input_vocab_size, output_vocab_size, hidden_size,
word_vec_dim, n_layers, bidirectional, variable_lengths,
use_attention, e... | 1,071 | 45.608696 | 85 | py |
CLOSURE | CLOSURE-master/vr/ns_vqa/attention.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class Attention(nn.Module):
"""Attention layer"""
def __init__(self, dim, use_weight=False, hidden_size=512):
super(Attention, self).__init__()
self.use_weight = use_weight
self.hidden_size = hidden_size
if use... | 1,804 | 38.23913 | 149 | py |
CLOSURE | CLOSURE-master/scripts/question_engine.py | # This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://github.com/rizar/CLOSURE/... | 9,688 | 30.767213 | 138 | py |
CLOSURE | CLOSURE-master/scripts/generate_templates.py | import json
import argparse
# "query" is the attribute that is queried
QUERY_PH = '%query%'
Q_PH = '%Q%'
# "attr" is the attribute that is used for reasoning
ATTR_PH = '%attr%'
A_PH = '%A%'
VALUES = [('color', 'C'), ('shape', 'S'),
('material', 'M'), ('size', 'Z')]
parser = argparse.ArgumentParser('Generat... | 1,221 | 28.804878 | 90 | py |
CLOSURE | CLOSURE-master/scripts/preprocess_questions.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://g... | 7,871 | 35.613953 | 138 | py |
CLOSURE | CLOSURE-master/scripts/run_pg.py | # This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://github.com/rizar/CLOSURE/... | 5,036 | 29.713415 | 138 | py |
CLOSURE | CLOSURE-master/scripts/train_model.py | #!/usr/bin/env python3
# This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://gi... | 60,588 | 45.642802 | 138 | py |
CLOSURE | CLOSURE-master/scripts/generate_questions.py | # This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://github.com/rizar/CLOSURE/... | 27,902 | 37.170999 | 138 | py |
CLOSURE | CLOSURE-master/scripts/rewrite_programs.py | import h5py
import os
import shutil
import sys
import json
import copy
import numpy
import time
import timeit
from vr.data import ClevrDataset
from vr.utils import load_vocab
def needs_shortcut(token):
return (token.startswith('filter_') # because "pointers" need not contain attribute info
or token.st... | 2,901 | 35.734177 | 99 | py |
CLOSURE | CLOSURE-master/scripts/run_model.py | # This code is released under the MIT License in association with the following paper:
#
# CLOSURE: Assessing Systematic Generalization of CLEVR Models (https://arxiv.org/abs/1912.05783).
#
# Full copyright and license information (including third party attribution) in the NOTICE file (https://github.com/rizar/CLOSURE/... | 11,896 | 36.648734 | 138 | py |
sarpy | sarpy-master/setup.py | """
Setup module for SarPy.
"""
import os
from setuptools import setup, find_packages
# Get the long description from the README file
here = os.path.abspath(os.path.dirname(__file__))
# Get the long description from the README file
with open(os.path.join(here, 'README.md'), 'r') as f:
long_description = f.read()
... | 3,049 | 36.195122 | 140 | py |
sarpy | sarpy-master/examples/polygon_example.py | """
Basic polygon example - this needs to be reworked
"""
import numpy
from matplotlib import pyplot
import time
from sarpy.geometry.geometry_elements import Polygon
def generate_random_polygon(segment_count=12):
"""
Generate the coordinates for a random polygon going from (-1, 0) to (1, 0) and back.
It... | 5,054 | 34.104167 | 106 | py |
sarpy | sarpy-master/examples/first_example.py | """
Basic First Example
===================
This indicates the basic functionality for reading a complex format data set. It
is intended that this script will be read, and the relevant portions run
individually.
Learning Python
----------------
It seems somewhat common for some users of sarpy to be experts in SAR, ... | 6,047 | 33.758621 | 116 | py |
sarpy | sarpy-master/tests/test_class_string.py | from sarpy.utils.review_class import check_classification
import unittest
class TestClassString(unittest.TestCase):
def test_class_str(self):
results_dict = check_classification('sarpy')
key = '__NO_CLASSIFICATION__'
if key in results_dict:
raise ValueError(
'The... | 408 | 33.083333 | 106 | py |
sarpy | sarpy-master/tests/__init__.py |
import os
import logging
parent_path = os.environ.get('SARPY_TEST_PATH', None)
if parent_path == 'NONE':
parent_path = None
if parent_path is not None:
parent_path = os.path.expanduser(parent_path)
if parent_path is not None and not os.path.isdir(parent_path):
raise IOError('SARPY_TEST_PATH is given as ... | 1,717 | 28.118644 | 116 | py |
sarpy | sarpy-master/tests/io/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/tests/io/received/test_crsd.py | import logging
import os
import json
import tempfile
import unittest
import shutil
import numpy.testing
from sarpy.io.received.crsd import CRSDReader, CRSDReader1, CRSDWriter1
from sarpy.io.received.converter import open_received
from sarpy.io.received.crsd_schema import get_schema_path
from tests import parse_file_e... | 6,802 | 47.942446 | 129 | py |
sarpy | sarpy-master/tests/io/received/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/tests/io/general/test_tre.py | from sarpy.io.general.nitf_elements.tres.registration import find_tre
from sarpy.io.general.nitf_elements.tres.unclass.ACFTA import ACFTA
import unittest
class TestTreRegistry(unittest.TestCase):
def test_find_tre(self):
the_tre = find_tre('ACFTA')
self.assertEqual(the_tre, ACFTA)
| 304 | 29.5 | 69 | py |
sarpy | sarpy-master/tests/io/general/test_nitf_headers.py | import os
import time
import logging
import json
import unittest
from sarpy.io.general.nitf import NITFDetails
from sarpy.io.general.nitf_elements.image import ImageSegmentHeader
from sarpy.io.general.nitf_elements.text import TextSegmentHeader
from sarpy.io.general.nitf_elements.graphics import GraphicsSegmentHeader
... | 5,793 | 45.352 | 126 | py |
sarpy | sarpy-master/tests/io/general/test_data_segment.py | import unittest
import numpy
from sarpy.io.general.format_function import ComplexFormatFunction
from sarpy.io.general.data_segment import NumpyArraySegment, SubsetSegment, \
BandAggregateSegment, BlockAggregateSegment, FileReadDataSegment
from io import BytesIO
class TestNumpyArraySegment(unittest.TestCase):
... | 19,452 | 42.228889 | 91 | py |
sarpy | sarpy-master/tests/io/general/test_format_function.py | import unittest
import numpy
from sarpy.io.general.format_function import IdentityFunction, ComplexFormatFunction
class TestIdentityFunction(unittest.TestCase):
def test_reverse(self):
base_data = numpy.reshape(numpy.arange(6, dtype='int32'), (3, 2))
for axis in [(0, ), (1, ), (0, 1)]:
... | 9,911 | 55.965517 | 116 | py |
sarpy | sarpy-master/tests/io/general/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/tests/io/general/test_base.py | import unittest
import numpy
from sarpy.io.general.format_function import ComplexFormatFunction
from sarpy.io.general.data_segment import NumpyArraySegment
from sarpy.io.general.base import BaseReader, BaseWriter
class TestBaseReader(unittest.TestCase):
def test_read(self):
data = numpy.reshape(numpy.ar... | 6,472 | 41.032468 | 87 | py |
sarpy | sarpy-master/tests/io/product/test_reader.py | import json
import logging
import lxml.etree
import os
import pathlib
import unittest
from sarpy.io.product.converter import open_product
from sarpy.io.product.sidd import SIDDReader
import sarpy.io.product.sidd
import sarpy.io.product.sidd3_elements.SIDD as sarpy_sidd3
from tests import parse_file_entry
product_fi... | 5,464 | 49.601852 | 135 | py |
sarpy | sarpy-master/tests/io/product/test_sidd_schema.py | #
# Copyright 2023 Valkyrie Systems Corporation
#
# Licensed under MIT License. See LICENSE.
#
import re
import lxml.etree
import pytest
import sarpy.io.product.sidd_schema as sarpy_sidd
@pytest.mark.parametrize('sidd_version', sarpy_sidd.get_versions())
def test_validate_xml_ns(sidd_version):
xml_ns, ns_key =... | 2,029 | 28.852941 | 86 | py |
sarpy | sarpy-master/tests/io/product/test_sidd_writing.py | import os
import json
import tempfile
import shutil
import unittest
from sarpy.io.complex.sicd import SICDReader
from sarpy.io.product.sidd import SIDDReader
from sarpy.io.product.sidd_schema import get_schema_path
from sarpy.processing.sidd.sidd_product_creation import create_detected_image_sidd, create_dynamic_image... | 6,799 | 42.589744 | 126 | py |
sarpy | sarpy-master/tests/io/product/__init__.py |
__classification__ = 'UNCLASSIFIED'
| 37 | 11.666667 | 35 | py |
sarpy | sarpy-master/tests/io/product/sidd3_elements/test_exploitationfeatures.py | #
# Copyright 2023 Valkyrie Systems Corporation
#
# Licensed under MIT License. See LICENSE.
#
import datetime
import itertools
import logging
import pathlib
import numpy as np
import pytest
import sarpy.geometry.geocoords
import sarpy.io.complex.sicd_elements.SCPCOA
from sarpy.io.complex.sicd_elements.SICD import S... | 3,799 | 36.254902 | 110 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.