code stringlengths 17 6.64M |
|---|
def randomString(stringLength=5):
letters = string.ascii_lowercase
return [random.choice(letters) for i in range(stringLength)]
|
def do_decode(decoder, src_sentences, trgt_sentences=None, num_log=1):
all_hypos = []
start_time = time.time()
logging.info(('Start time: %s' % start_time))
for (sen_idx, src) in enumerate(src_sentences):
decoder.set_current_sen_id(sen_idx)
logging.info(('Next sentence (ID: %d): %s' % ... |
def compare_decoders(decoder1, decoder2, src_sentences, early_stopping=False, num_log=1):
all_hypos1 = do_decode(decoder1, src_sentences, num_log=num_log)
print('-------------------')
all_hypos2 = do_decode(decoder2, src_sentences, num_log=num_log)
for (sentences1, sentences2) in zip(all_hypos1, all_h... |
def test_utils():
'\n TODO: add more tests\n '
from arsenal.maths import assert_equal
for (a, b) in np.random.uniform(0, 10, size=(100, 2)):
if (a < b):
(a, b) = (b, a)
want = np.log((a - b))
assert_equal(want, utils.log_minus(np.log(a), np.log(b)), 'log sub')
... |
def str2bool(v):
'For making the ``ArgumentParser`` understand boolean values'
return (v.lower() in ('yes', 'true', 't', '1'))
|
def run_diagnostics():
'Check availability of external libraries.'
OKGREEN = '\x1b[92m'
FAIL = '\x1b[91m'
ENDC = '\x1b[0m'
if (sys.version_info > (3, 0)):
print(('Checking Python3.... %sOK (%s)%s' % (OKGREEN, platform.python_version(), ENDC)))
else:
print(('Checking Python3....... |
def get_parser():
'Get the parser object which is used to build the configuration\n argument ``args``. This is a helper method for ``get_args()``\n TODO: Decentralize configuration\n \n Returns:\n ArgumentParser. The pre-filled parser object\n '
parser = argparse.ArgumentParser()
par... |
def parse_args(parser):
(args, _) = parser.parse_known_args()
if (args.decoder is not None):
decoding.DECODER_REGISTRY[args.decoder].add_args(parser)
if (args.predictor is not None):
import predictors
predictors.PREDICTOR_REGISTRY[args.predictor].add_args(parser)
return parser.... |
def get_args():
parser = get_parser()
args = parse_args(parser)
return args
|
def validate_args(args):
'Some rudimentary sanity checks for configuration options.\n This method directly prints help messages to the user. In case of fatal\n errors, it terminates using ``logging.fatal()``\n \n Args:\n args (object): Configuration as returned by ``get_args``\n '
if (a... |
def switch_to_fairseq_indexing():
'Calling this method overrides the global definitions of the \n reserved word ids ``GO_ID``, ``EOS_ID``, and ``UNK_ID``\n with the fairseq indexing scheme. \n '
global GO_ID
global EOS_ID
global UNK_ID
GO_ID = 0
EOS_ID = 2
UNK_ID = 3
|
def switch_to_t2t_indexing():
'Calling this method overrides the global definitions of the \n reserved word ids ``GO_ID``, ``EOS_ID``, and ``UNK_ID``\n with the tensor2tensor indexing scheme. This scheme is used in all\n t2t models. \n '
global GO_ID
global EOS_ID
global UNK_ID
GO_ID ... |
def log_sum_tropical_semiring(vals):
'Approximates summation in log space with the max.\n \n Args:\n vals (set): List or set of numerical values\n '
return max(vals)
|
def log_sum_log_semiring(vals):
'Uses the ``logsumexp`` function in scipy to calculate the log of\n the sum of a set of log values.\n \n Args:\n vals (set): List or set of numerical values\n '
return logsumexp(np.asarray([val for val in vals]))
|
def oov_to_unk(seq, vocab_size, unk_idx=None):
if (unk_idx is None):
unk_idx = UNK_ID
return [(x if (x < vocab_size) else unk_idx) for x in seq]
|
def argmax_n(arr, n):
'Get indices of the ``n`` maximum entries in ``arr``. The \n parameter ``arr`` can be a dictionary. The returned index set is \n not guaranteed to be sorted.\n \n Args:\n arr (list,array,dict): Set of numerical values\n n (int): Number of values to retrieve\n ... |
def max_(arr):
'Get indices of the ``n`` maximum entries in ``arr``. The \n parameter ``arr`` can be a dictionary. The returned index set is \n not guaranteed to be sorted.\n \n Args:\n arr (list,array,dict): Set of numerical values\n n (int): Number of values to retrieve\n \n R... |
def argmax(arr):
'Get the index of the maximum entry in ``arr``. The parameter can\n be a dictionary.\n \n Args:\n arr (list,array,dict): Set of numerical values\n \n Returns:\n Index or key of the maximum entry in ``arr``\n '
if isinstance(arr, dict):
return max(arr.i... |
def flattened(X):
'flattens list of lists'
return [y for x in X for y in x]
|
def as_ndarray(X, pad=(- 1), min_length=0):
'turns list of lists into ndarray'
longest = max(len(max(X, key=len)), min_length)
return np.array([(i + ([pad] * (longest - len(i)))) for i in X])
|
def log1mexp_basic(x, ignore_zero=False):
'\n Vectorizable implementation of log(1-exp(x))\n '
if ignore_zero:
with np.errstate(divide='ignore'):
return np.log1p((- np.exp(x)))
return np.log1p((- np.exp(x)))
|
def log1pexp_basic(x, ignore_zero=False):
'\n Vectorizable implementation of log(1+exp(x))\n '
if ignore_zero:
with np.errstate(divide='ignore'):
return np.log1p(np.exp(x))
return np.log1p(np.exp(x))
|
def log1pexp(x):
'\n Numerically stable implementation of log(1+exp(x)) aka softmax(0,x).\n\n -log1pexp(-x) is log(sigmoid(x))\n\n Source:\n http://cran.r-project.org/web/packages/Rmpfr/vignettes/log1mexp-note.pdf\n '
if (x <= (- 37)):
return np.exp(x)
elif ((- 37) <= x <= 18):
... |
def log1mexp(x):
'\n Numerically stable implementation of log(1-exp(x))\n\n Note: function is finite for x < 0.\n\n Source:\n http://cran.r-project.org/web/packages/Rmpfr/vignettes/log1mexp-note.pdf\n '
if (x >= 0):
return np.nan
else:
a = abs(x)
if (0 < a <= 0.693):... |
def log_add(x, y):
'\n Addition of 2 values in log space.\n Need separate checks for inf because inf-inf=nan\n '
if (x == NEG_INF):
return y
elif (y == NEG_INF):
return x
else:
if (y <= x):
d = (y - x)
r = x
else:
d = (x - y)... |
def log_minus(x, y):
'\n Subtractioon of 2 values in log space.\n Need separate checks for inf because inf-inf=nan\n '
if (x == y):
return NEG_INF
if (y > x):
if ((y - x) > MACHINE_EPS):
logging.warn('Using function log_minus for invalid values')
return np.nan
... |
def logsigmoid(x):
'\n log(sigmoid(x)) = -log(1+exp(-x)) = -log1pexp(-x)\n '
return (- log1pexp((- x)))
|
def signed_log_add(x, y, sign_x, sign_y):
(a, b) = (x, y)
(sign_a, sign_b) = (sign_x, sign_y)
if (y > x):
(a, b) = (y, x)
(sign_a, sign_b) = (sign_y, sign_x)
if (sign_a != sign_b):
val = log_minus(a, b)
else:
val = log_add(a, b)
return (sign_a, val)
|
def softmax(x, temperature=1.0):
return np.exp(log_softmax(x, temperature=temperature))
|
def log_softmax(x, temperature=1.0):
x = (x / temperature)
shift_x = (x - np.max(x))
b = (~ np.ma.masked_invalid(shift_x).mask).astype(int)
return (shift_x - logsumexp(shift_x, b=b))
|
def binary_search(a, x):
i = bisect_left(a, x)
if ((i != len(a)) and (a[i] == x)):
return i
else:
return (- 1)
|
def perplexity(arr):
if (len(arr) == 0):
return INF
score = sum([s for s in arr])
return (2 ** ((- score) / len(arr)))
|
def prod(iterable):
return reduce(operator.mul, iterable, 1.0)
|
def common_viewkeys(obj):
'Can be used to iterate over the keys or indices of a mapping.\n Works with numpy arrays, lists, and dicts. Code taken from\n http://stackoverflow.com/questions/12325608/iterate-over-a-dict-or-list-in-python\n '
if isinstance(obj, dict):
return obj.keys()
else:
... |
def common_iterable(obj):
'Can be used to iterate over the key-value pairs of a mapping.\n Works with numpy arrays, lists, and dicts. Code taken from\n http://stackoverflow.com/questions/12325608/iterate-over-a-dict-or-list-in-python\n '
if isinstance(obj, dict):
for (key, value) in obj.items... |
def common_get(obj, key, default):
'Can be used to access an element via the index or key.\n Works with numpy arrays, lists, and dicts.\n \n Args:\n ``obj`` (list,array,dict): Mapping\n ``key`` (int): Index or key of the element to retrieve\n ``default`` (object): Default return val... |
def common_contains(obj, key):
'Checks the existence of a key or index in a mapping.\n Works with numpy arrays, lists, and dicts.\n \n Args:\n ``obj`` (list,array,dict): Mapping\n ``key`` (int): Index or key of the element to retrieve\n \n Returns:\n ``True`` if ``key`` in ``o... |
def get_path(tmpl, sub=1):
'Replaces the %d placeholder in ``tmpl`` with ``sub``. If ``tmpl``\n does not contain %d, return ``tmpl`` unmodified.\n \n Args:\n tmpl (string): Path, potentially with %d placeholder\n sub (int): Substitution for %d\n \n Returns:\n string. ``tmpl`` w... |
def split_comma(s, func=None):
'Splits a string at commas and removes blanks.'
if (not s):
return []
parts = s.split(',')
if (func is None):
return [el.strip() for el in parts]
return [func(el.strip()) for el in parts]
|
def ngrams(sen, n):
sen = sen.split(' ')
output = []
for i in range(((len(sen) - n) + 1)):
output.append(tuple(sen[i:(i + n)]))
return output
|
def distinct_ngrams(hypos, n):
total_ngrams = 0
distinct = []
for h in hypos:
all_ngrams = ngrams(h, n)
total_ngrams += len(all_ngrams)
distinct.extend(all_ngrams)
if (len(distinct) == 0):
return 0
return (float(len(set(distinct))) / len(distinct))
|
def ngram_diversity(hypos):
ds = [distinct_ngrams(hypos, i) for i in range(1, 5)]
return (sum(ds) / 4)
|
def hamming_distance(hypo, other_hypos, pad=(- 1)):
if isinstance(other_hypos, np.ndarray):
if (len(hypo) != other_hypos.shape[1]):
hypo = np.array((hypo + ([pad] * (other_hypos.shape[1] - len(hypo)))))
return (hypo != other_hypos).sum()
elif isinstance(other_hypos, list):
... |
def sentence_bleu(sentence, reference, detokenizer=None):
'\n Utility function for calculating sentence BLEU. \n Expects sentence and reference as list of tokens.\n Reference may be list of multiple references\n '
if (not isinstance(reference[0], list)):
reference = [reference]
if (det... |
def entropy(distribution, base=np.e):
return (- sum((distribution * np.log(distribution, base=base))))
|
def log_entropy(log_distribution, base=np.e):
return (- sum(((base ** log_distribution) * log_distribution)))
|
class Discriminator(object):
def __init__(self, encoder_rnn_output, temperature, is_training=True, ru=False):
with tf.variable_scope('Discriminator_input'):
self.encoder_rnn_output = encoder_rnn_output
self.temperature = temperature
self.is_training = is_training
... |
class Encoder_cvae(object):
def __init__(self, embedding, encoder_input_list, is_training=True, ru=False):
with tf.name_scope('encoder_input'):
self.embedding = embedding
self.encoder_input_list = encoder_input_list
self.is_training = is_training
with tf.variab... |
class Sampler(object):
def __init__(self, encoder_rnn_output, label_onehot, is_training=True):
self.encoder_rnn_output = encoder_rnn_output
self.label_onehot = label_onehot
self.is_training = is_training
with tf.variable_scope('encoder_linear1'):
context_to_hidden_W = ... |
class Encoder_vae(object):
def __init__(self, embedding, encoder_input_list, is_training=True, ru=False):
with tf.variable_scope('Encoder_input'):
self.embedding = embedding
self.encoder_input_list = encoder_input_list
self.is_training = is_training
with tf.var... |
class Semi_VAE(object):
def __init__(self, batchloader, is_training=True, without_label=False, ru=False):
self.batchloader = batchloader
self.ru = ru
self.is_training = is_training
self.without_label = without_label
self.lr = tf.placeholder(tf.float32, shape=(), name='lear... |
class Simple_VAE(object):
def __init__(self, batchloader, is_training=True, ru=False):
self.batchloader = batchloader
self.ru = ru
self.is_training = is_training
self.lr = tf.placeholder(tf.float32, shape=(), name='learning_rate')
with tf.name_scope('Placeholders'):
... |
def sampling():
batchloader = BatchLoader(with_label=True)
sess_conf = tf.ConfigProto(gpu_options=tf.GPUOptions())
with tf.Graph().as_default():
with tf.Session(config=sess_conf) as sess:
with tf.variable_scope('VAE'):
vae_restored = VAE[FLAGS.VAE_NAME](batchloader, is_... |
def log_and_print(log_file, logstr, br=True):
print(logstr)
if br:
logstr = (logstr + '\n')
with open(log_file, 'a') as f:
f.write(logstr)
|
def main():
os.mkdir(FLAGS.LOG_DIR)
os.mkdir((FLAGS.LOG_DIR + '/model'))
log_file = (FLAGS.LOG_DIR + '/log.txt')
shutil.copyfile('config.py', (FLAGS.LOG_DIR + '/config.py'))
shutil.copyfile('README.md', (FLAGS.LOG_DIR + '/README.md'))
sess_conf = tf.ConfigProto(gpu_options=tf.GPUOptions())
... |
def log_and_print(log_file, logstr, br=True):
print(logstr)
if br:
logstr = (logstr + '\n')
with open(log_file, 'a') as f:
f.write(logstr)
|
def main():
os.mkdir(FLAGS.LOG_DIR)
os.mkdir((FLAGS.LOG_DIR + '/model'))
log_file = (FLAGS.LOG_DIR + '/log.txt')
shutil.copyfile('config.py', (FLAGS.LOG_DIR + '/config.py'))
shutil.copyfile('README.md', (FLAGS.LOG_DIR + '/README.md'))
sess_conf = tf.ConfigProto(gpu_options=tf.GPUOptions())
... |
class BatchLoader():
def __init__(self, with_label=True):
self.with_label = with_label
self.go_token = '<GO>'
self.pad_token = '<PAD>'
self.unk_token = '<UNK>'
with open(FLAGS.DATA_PATH, 'rb') as f:
data = pkl.load(f)
if self.with_label:
wit... |
def collect_torch_env() -> str:
try:
import torch.__config__
return torch.__config__.show()
except ImportError:
from torch.utils.collect_env import get_pretty_env_info
return get_pretty_env_info()
|
def get_env_module() -> Tuple[str]:
var_name = 'ENV_MODULE'
return (var_name, os.environ.get(var_name, '<not set>'))
|
def collect_env_info() -> str:
data = []
data.append(('Python', sys.version.replace('\n', '')))
data.append(get_env_module())
data.append(('PyTorch', torch.__version__))
data.append(('PyTorch Debug Build', torch.version.debug))
has_cuda = torch.cuda.is_available()
data.append(('CUDA availa... |
def default_argument_parser():
'\n create a simple parser to wrap around config file\n '
parser = argparse.ArgumentParser(description='visual-prompt')
parser.add_argument('--config-file', default='', metavar='FILE', help='path to config file')
parser.add_argument('--train-type', default='', help... |
def logging_train_setup(args, cfg) -> None:
output_dir = cfg.OUTPUT_DIR
if output_dir:
PathManager.mkdirs(output_dir)
logger = logging.setup_logging(cfg.NUM_GPUS, get_world_size(), output_dir, name='visual_prompt')
rank = get_rank()
logger.info(f'Rank of current process: {rank}. World size... |
def get_cfg():
'\n Get a copy of the default config.\n '
return _C.clone()
|
class CfgNode(_CfgNode):
'\n The same as `fvcore.common.config.CfgNode`, but different in:\n\n support manifold path\n '
@classmethod
def _open_cfg(cls, filename):
return PathManager.open(filename, 'r')
def dump(self, *args, **kwargs):
'\n Returns:\n str: a... |
def get_testing():
'Returns a minimal configuration for testing.'
config = ml_collections.ConfigDict()
config.patches = ml_collections.ConfigDict({'size': (16, 16)})
config.hidden_size = 1
config.transformer = ml_collections.ConfigDict()
config.transformer.mlp_dim = 1
config.transformer.nu... |
def get_b16_config():
'Returns the ViT-B/16 configuration.'
config = ml_collections.ConfigDict()
config.patches = ml_collections.ConfigDict({'size': (16, 16)})
config.hidden_size = 768
config.transformer = ml_collections.ConfigDict()
config.transformer.mlp_dim = 3072
config.transformer.num... |
def get_r50_b16_config():
'Returns the Resnet50 + ViT-B/16 configuration.'
config = get_b16_config()
del config.patches.size
config.patches.grid = (14, 14)
config.resnet = ml_collections.ConfigDict()
config.resnet.num_layers = (3, 4, 9)
config.resnet.width_factor = 1
return config
|
def get_b32_config():
'Returns the ViT-B/32 configuration.'
config = get_b16_config()
config.patches.size = (32, 32)
return config
|
def get_b8_config():
'Returns the ViT-B/32 configuration.'
config = get_b16_config()
config.patches.size = (8, 8)
return config
|
def get_l16_config():
'Returns the ViT-L/16 configuration.'
config = ml_collections.ConfigDict()
config.patches = ml_collections.ConfigDict({'size': (16, 16)})
config.hidden_size = 1024
config.transformer = ml_collections.ConfigDict()
config.transformer.mlp_dim = 4096
config.transformer.nu... |
def get_l32_config():
'Returns the ViT-L/32 configuration.'
config = get_l16_config()
config.patches.size = (32, 32)
return config
|
def get_h14_config():
'Returns the ViT-L/16 configuration.'
config = ml_collections.ConfigDict()
config.patches = ml_collections.ConfigDict({'size': (14, 14)})
config.hidden_size = 1280
config.transformer = ml_collections.ConfigDict()
config.transformer.mlp_dim = 5120
config.transformer.nu... |
class JSONDataset(torch.utils.data.Dataset):
def __init__(self, cfg, split):
assert (split in {'train', 'val', 'test'}), "Split '{}' not supported for {} dataset".format(split, cfg.DATA.NAME)
logger.info('Constructing {} dataset {}...'.format(cfg.DATA.NAME, split))
self.cfg = cfg
... |
class CUB200Dataset(JSONDataset):
'CUB_200 dataset.'
def __init__(self, cfg, split):
super(CUB200Dataset, self).__init__(cfg, split)
def get_imagedir(self):
return os.path.join(self.data_dir, 'images')
|
class CarsDataset(JSONDataset):
'stanford-cars dataset.'
def __init__(self, cfg, split):
super(CarsDataset, self).__init__(cfg, split)
def get_imagedir(self):
return self.data_dir
|
class DogsDataset(JSONDataset):
'stanford-dogs dataset.'
def __init__(self, cfg, split):
super(DogsDataset, self).__init__(cfg, split)
def get_imagedir(self):
return os.path.join(self.data_dir, 'Images')
|
class FlowersDataset(JSONDataset):
'flowers dataset.'
def __init__(self, cfg, split):
super(FlowersDataset, self).__init__(cfg, split)
def get_imagedir(self):
return self.data_dir
|
class NabirdsDataset(JSONDataset):
'Nabirds dataset.'
def __init__(self, cfg, split):
super(NabirdsDataset, self).__init__(cfg, split)
def get_imagedir(self):
return os.path.join(self.data_dir, 'images')
|
class TFDataset(torch.utils.data.Dataset):
def __init__(self, cfg, split):
assert (split in {'train', 'val', 'test', 'trainval'}), "Split '{}' not supported for {} dataset".format(split, cfg.DATA.NAME)
logger.info('Constructing {} dataset {}...'.format(cfg.DATA.NAME, split))
self.cfg = cf... |
def preprocess_fn(data, size=224, input_range=(0.0, 1.0)):
image = data['image']
image = tf.image.resize(image, [size, size])
image = (tf.cast(image, tf.float32) / 255.0)
image = ((image * (input_range[1] - input_range[0])) + input_range[0])
data['image'] = image
return data
|
def build_tf_dataset(cfg, mode):
'\n Builds a tf data instance, then transform to a list of tensors and labels\n '
if (mode not in ['train', 'val', 'test', 'trainval']):
raise ValueError('The input pipeline supports `train`, `val`, `test`.Provided mode is {}'.format(mode))
vtab_dataname = cf... |
def to_torch_imgs(img: np.ndarray, mean: Tensor, std: Tensor) -> Tensor:
t_img: Tensor = torch.from_numpy(np.transpose(img, (2, 0, 1)))
t_img -= mean
t_img /= std
return t_img
|
def _construct_loader(cfg, split, batch_size, shuffle, drop_last):
'Constructs the data loader for the given dataset.'
dataset_name = cfg.DATA.NAME
if dataset_name.startswith('vtab-'):
from .datasets.tf_dataset import TFDataset
dataset = TFDataset(cfg, split)
else:
assert (data... |
def construct_train_loader(cfg):
'Train loader wrapper.'
if (cfg.NUM_GPUS > 1):
drop_last = True
else:
drop_last = False
return _construct_loader(cfg=cfg, split='train', batch_size=int((cfg.DATA.BATCH_SIZE / cfg.NUM_GPUS)), shuffle=True, drop_last=drop_last)
|
def construct_trainval_loader(cfg):
'Train loader wrapper.'
if (cfg.NUM_GPUS > 1):
drop_last = True
else:
drop_last = False
return _construct_loader(cfg=cfg, split='trainval', batch_size=int((cfg.DATA.BATCH_SIZE / cfg.NUM_GPUS)), shuffle=True, drop_last=drop_last)
|
def construct_test_loader(cfg):
'Test loader wrapper.'
return _construct_loader(cfg=cfg, split='test', batch_size=int((cfg.DATA.BATCH_SIZE / cfg.NUM_GPUS)), shuffle=False, drop_last=False)
|
def construct_val_loader(cfg, batch_size=None):
if (batch_size is None):
bs = int((cfg.DATA.BATCH_SIZE / cfg.NUM_GPUS))
else:
bs = batch_size
'Validation loader wrapper.'
return _construct_loader(cfg=cfg, split='val', batch_size=bs, shuffle=False, drop_last=False)
|
def shuffle(loader, cur_epoch):
'"Shuffles the data.'
assert isinstance(loader.sampler, (RandomSampler, DistributedSampler)), "Sampler type '{}' not supported".format(type(loader.sampler))
if isinstance(loader.sampler, DistributedSampler):
loader.sampler.set_epoch(cur_epoch)
|
def get_transforms(split, size):
normalize = tv.transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
if (size == 448):
resize_dim = 512
crop_dim = 448
elif (size == 224):
resize_dim = 256
crop_dim = 224
elif (size == 384):
resize_dim = 438... |
def make_get_tensors_fn(output_tensors):
'Create a function that outputs a collection of tensors from the dataset.'
def _get_fn(data):
'Get tensors by name.'
return {tensor_name: data[tensor_name] for tensor_name in output_tensors}
return _get_fn
|
def make_get_and_cast_tensors_fn(output_tensors):
'Create a function that gets and casts a set of tensors from the dataset.\n\n Optionally, you can also rename the tensors.\n\n Examples:\n # This simply gets "image" and "label" tensors without any casting.\n # Note that this is equivalent to make_get_tens... |
def compose_preprocess_fn(*functions):
'Compose two or more preprocessing functions.\n\n Args:\n *functions: Sequence of preprocess functions to compose.\n\n Returns:\n The composed function.\n '
def _composed_fn(x):
for fn in functions:
if (fn is not None):
x = f... |
@six.add_metaclass(abc.ABCMeta)
class ImageDataInterface(object):
'Interface to the image data classes.'
@property
@abc.abstractmethod
def default_label_key(self):
'Returns the default label key of the dataset.'
@property
@abc.abstractmethod
def label_keys(self):
'Returns... |
class ImageData(ImageDataInterface):
'Abstract data provider class.\n\n IMPORTANT: You should use ImageTfdsData below whenever is posible. We want\n to use as many datasets in TFDS as possible to ensure reproducibility of our\n experiments. Your data class should only inherit directly from this if you\n are d... |
class ImageTfdsData(ImageData):
'Abstract data provider class for datasets available in Tensorflow Datasets.\n\n To add new datasets inherit from this class. This class implements a simple\n API that is used throughout the project and provides standardized way of data\n preprocessing and batching.\n '
@a... |
@Registry.register('data.caltech101', 'class')
class Caltech101(base.ImageTfdsData):
'Provides the Caltech101 dataset.\n\n See the base class for additional details on the class.\n\n See TFDS dataset for details on the dataset:\n third_party/py/tensorflow_datasets/image/caltech.py\n\n The original (TFDS) data... |
@Registry.register('data.cifar', 'class')
class CifarData(base.ImageTfdsData):
'Provides Cifar10 or Cifar100 data.\n\n Cifar comes only with a training and test set. Therefore, the validation set\n is split out of the original training set, and the remaining examples are used\n as the "train" split. The "train... |
@Registry.register('data.diabetic_retinopathy', 'class')
class RetinopathyData(base.ImageTfdsData):
'Provides Diabetic Retinopathy classification data.\n\n Retinopathy comes only with a training and test set. Therefore, the validation\n set is split out of the original training set, and the remaining examples a... |
@Registry.register('data.dmlab', 'class')
class DmlabData(base.ImageTfdsData):
'Dmlab dataset.\n\n The Dmlab dataset contains frames observed by the agent acting in the\n DMLab environment, which are annotated by the distance between\n the agent and various objects present in the environment. The g... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.