Dataset Viewer
repo_name
stringclasses 6
values | hexsha
stringclasses 6
values | file_path
stringclasses 6
values | code
stringclasses 6
values | apis
sequence | extract_api
stringclasses 6
values |
---|---|---|---|---|---|
adcrn/knest | a274dc9ddb642cc30f837e225f000bf33430eb43 | utils/compare.py | # UCF Senior Design 2017-18
# Group 38
from PIL import Image
import cv2
import imagehash
import math
import numpy as np
DIFF_THRES = 20
LIMIT = 2
RESIZE = 1000
def calc_hash(img):
"""
Calculate the wavelet hash of the image
img: (ndarray) image file
"""
# resize image if height > 1000
img = resize(img)
return imagehash.whash(Image.fromarray(img))
def compare(hash1, hash2):
"""
Calculate the difference between two images
hash1: (array) first wavelet hash
hash2: (array) second wavelet hash
"""
return hash1 - hash2
def limit(img, std_hash, count):
"""
Determine whether image should be removed from image dictionary in main.py
img: (ndarray) image file
std_hash: (array) wavelet hash of comparison standard
count: (int) global count of images similar to comparison standard
"""
# calculate hash for given image
cmp_hash = calc_hash(img)
# compare to standard
diff = compare(std_hash, cmp_hash)
# image is similar to standard
if diff <= DIFF_THRES:
# if there are 3 similar images already, remove image
if count >= LIMIT:
return 'remove'
# non-similar image found
else:
# update comparison standard
return 'update_std'
# else continue reading images with same standard
return 'continue'
def resize(img):
"""
Resize an image
img: (ndarray) RGB color image
"""
# get dimensions of image
width = np.shape(img)[1]
height = np.shape(img)[0]
# if height of image is greater than 1000, resize it to 1000
if width > RESIZE:
# keep resize proportional
scale = RESIZE / width
resized_img = cv2.resize(
img, (RESIZE, math.floor(height / scale)), cv2.INTER_AREA)
# return resized image
return resized_img
# if height of image is less than 1000, return image unresized
return img
def set_standard(images, filename):
"""
Set new comparison standard and update information
images: (dictionary) dictionary containing all the image data
filename: (String) name of the image file
"""
return filename, calc_hash(images[filename]), 0
| [
"numpy.shape"
] | [(22, 'PIL.Image.fromarray', 'Image.fromarray', (['img'], {}), False, 'from PIL import Image\n'), (68, 'numpy.shape', 'np.shape', (['img'], {}), True, 'import numpy as np\n'), (69, 'numpy.shape', 'np.shape', (['img'], {}), True, 'import numpy as np\n'), (76, 'math.floor', 'math.floor', (['(height / scale)'], {}), False, 'import math\n')] |
dongmengshi/easylearn | df528aaa69c3cf61f5459a04671642eb49421dfb | eslearn/utils/lc_featureSelection_variance.py | # -*- coding: utf-8 -*-
"""
Created on Tue Jul 24 14:38:20 2018
dimension reduction with VarianceThreshold using sklearn.
Feature selector that removes all low-variance features.
@author: lenovo
"""
from sklearn.feature_selection import VarianceThreshold
import numpy as np
#
np.random.seed(1)
X = np.random.randn(100, 10)
X = np.hstack([X, np.zeros([100, 5])])
#
def featureSelection_variance(X, thrd):
sel = VarianceThreshold(threshold=thrd)
X_selected = sel.fit_transform(X)
mask = sel.get_support()
return X_selected, mask
X = [[0, 2, 0, 3], [0, 1, 4, 3], [0, 1, 1, 3]]
selector = VarianceThreshold()
selector.fit_transform(X)
selector.variances_
| [
"numpy.zeros",
"numpy.random.seed",
"numpy.random.randn",
"sklearn.feature_selection.VarianceThreshold"
] | [(11, 'numpy.random.seed', 'np.random.seed', (['(1)'], {}), True, 'import numpy as np\n'), (12, 'numpy.random.randn', 'np.random.randn', (['(100)', '(10)'], {}), True, 'import numpy as np\n'), (25, 'sklearn.feature_selection.VarianceThreshold', 'VarianceThreshold', ([], {}), False, 'from sklearn.feature_selection import VarianceThreshold\n'), (18, 'sklearn.feature_selection.VarianceThreshold', 'VarianceThreshold', ([], {'threshold': 'thrd'}), False, 'from sklearn.feature_selection import VarianceThreshold\n'), (13, 'numpy.zeros', 'np.zeros', (['[100, 5]'], {}), True, 'import numpy as np\n')] |
silent567/examples | e9de12549125ecd93a4924f6b8e2bbf66d7635d9 | mnist/my_multi_tune3.py | #!/usr/bin/env python
# coding=utf-8
from my_multi_main3 import main
import numpy as np
import argparse
import time
parser = argparse.ArgumentParser(description='PyTorch MNIST Example')
parser.add_argument('--batch-size', type=int, default=64, metavar='N',
help='input batch size for training (default: 64)')
parser.add_argument('--test-batch-size', type=int, default=1000, metavar='N',
help='input batch size for testing (default: 1000)')
parser.add_argument('--epochs', type=int, default=10, metavar='N',
help='number of epochs to train (default: 10)')
parser.add_argument('--lr', type=float, default=0.01, metavar='LR',
help='learning rate (default: 0.01)')
parser.add_argument('--momentum', type=float, default=0.5, metavar='M',
help='SGD momentum (default: 0.5)')
parser.add_argument('--no-cuda', action='store_true', default=False,
help='disables CUDA training')
parser.add_argument('--seed', type=int, default=1, metavar='S',
help='random seed (default: 1)')
parser.add_argument('--log-interval', type=int, default=10, metavar='N',
help='how many batches to wait before logging training status')
parser.add_argument('--save-model', action='store_true', default=False,
help='For Saving the current Model')
parser.add_argument('--norm-flag', type=bool, default=False,
help='Triggering the Layer Normalization flag for attention scores')
parser.add_argument('--gamma', type=float, default=None,
help='Controlling the sparisty of gfusedmax/sparsemax, the smaller, the more sparse')
parser.add_argument('--lam', type=float, default=1.0,
help='Lambda: Controlling the smoothness of gfusedmax, the larger, the smoother')
parser.add_argument('--max-type', type=str, default='softmax',choices=['softmax','sparsemax','gfusedmax'],
help='mapping function in attention')
parser.add_argument('--optim-type', type=str, default='SGD',choices=['SGD','Adam'],
help='mapping function in attention')
parser.add_argument('--head-cnt', type=int, default=2, metavar='S', choices=[1,2,4,5,10],
help='Number of heads for attention (default: 1)')
args = parser.parse_args()
hyperparameter_choices = {
'lr':list(10**np.arange(-4,-1,0.5)),
'norm_flag': [True,False],
'gamma':list(10**np.arange(-1,3,0.5))+[None,],
'lam':list(10**np.arange(-2,2,0.5)),
'max_type':['softmax','sparsemax','gfusedmax'],
# 'max_type':['sparsemax'],
'optim_type':['SGD','Adam'],
'head_cnt':[1,2,4,5,10,20]
}
param_num = 25
record = np.zeros([param_num,len(hyperparameter_choices)+1])
record_name = 'record3_multi_%s.csv'%time.strftime('%Y-%m-%d_%H-%M-%S',time.localtime())
for n in range(param_num):
for param_index,(k,v) in enumerate(hyperparameter_choices.items()):
print(param_index,k)
value_index = np.random.choice(len(v))
if isinstance(v[value_index],str) or isinstance(v[value_index],bool) or v[value_index] is None:
record[n,param_index] = value_index
else:
record[n,param_index] = v[value_index]
setattr(args,k,v[value_index])
record[n,-1] = main(args)
np.savetxt(record_name, record, delimiter=',')
| [
"numpy.arange",
"numpy.savetxt"
] | [(9, 'argparse.ArgumentParser', 'argparse.ArgumentParser', ([], {'description': '"""PyTorch MNIST Example"""'}), False, 'import argparse\n'), (66, 'my_multi_main3.main', 'main', (['args'], {}), False, 'from my_multi_main3 import main\n'), (67, 'numpy.savetxt', 'np.savetxt', (['record_name', 'record'], {'delimiter': '""","""'}), True, 'import numpy as np\n'), (56, 'time.localtime', 'time.localtime', ([], {}), False, 'import time\n'), (44, 'numpy.arange', 'np.arange', (['(-4)', '(-1)', '(0.5)'], {}), True, 'import numpy as np\n'), (47, 'numpy.arange', 'np.arange', (['(-2)', '(2)', '(0.5)'], {}), True, 'import numpy as np\n'), (46, 'numpy.arange', 'np.arange', (['(-1)', '(3)', '(0.5)'], {}), True, 'import numpy as np\n')] |
neonbjb/DL-Art-School | a6f0f854b987ac724e258af8b042ea4459a571bc | codes/data/image_corruptor.py | import functools
import random
from math import cos, pi
import cv2
import kornia
import numpy as np
import torch
from kornia.augmentation import ColorJitter
from data.util import read_img
from PIL import Image
from io import BytesIO
# Get a rough visualization of the above distribution. (Y-axis is meaningless, just spreads data)
from utils.util import opt_get
'''
if __name__ == '__main__':
import numpy as np
import matplotlib.pyplot as plt
data = np.asarray([get_rand() for _ in range(5000)])
plt.plot(data, np.random.uniform(size=(5000,)), 'x')
plt.show()
'''
def kornia_color_jitter_numpy(img, setting):
if setting * 255 > 1:
# I'm using Kornia's ColorJitter, which requires pytorch arrays in b,c,h,w format.
img = torch.from_numpy(img).permute(2,0,1).unsqueeze(0)
img = ColorJitter(setting, setting, setting, setting)(img)
img = img.squeeze(0).permute(1,2,0).numpy()
return img
# Performs image corruption on a list of images from a configurable set of corruption
# options.
class ImageCorruptor:
def __init__(self, opt):
self.opt = opt
self.reset_random()
self.blur_scale = opt['corruption_blur_scale'] if 'corruption_blur_scale' in opt.keys() else 1
self.fixed_corruptions = opt['fixed_corruptions'] if 'fixed_corruptions' in opt.keys() else []
self.num_corrupts = opt['num_corrupts_per_image'] if 'num_corrupts_per_image' in opt.keys() else 0
self.cosine_bias = opt_get(opt, ['cosine_bias'], True)
if self.num_corrupts == 0:
return
else:
self.random_corruptions = opt['random_corruptions'] if 'random_corruptions' in opt.keys() else []
def reset_random(self):
if 'random_seed' in self.opt.keys():
self.rand = random.Random(self.opt['random_seed'])
else:
self.rand = random.Random()
# Feeds a random uniform through a cosine distribution to slightly bias corruptions towards "uncorrupted".
# Return is on [0,1] with a bias towards 0.
def get_rand(self):
r = self.rand.random()
if self.cosine_bias:
return 1 - cos(r * pi / 2)
else:
return r
def corrupt_images(self, imgs, return_entropy=False):
if self.num_corrupts == 0 and not self.fixed_corruptions:
if return_entropy:
return imgs, []
else:
return imgs
if self.num_corrupts == 0:
augmentations = []
else:
augmentations = random.choices(self.random_corruptions, k=self.num_corrupts)
# Sources of entropy
corrupted_imgs = []
entropy = []
undo_fns = []
applied_augs = augmentations + self.fixed_corruptions
for img in imgs:
for aug in augmentations:
r = self.get_rand()
img, undo_fn = self.apply_corruption(img, aug, r, applied_augs)
if undo_fn is not None:
undo_fns.append(undo_fn)
for aug in self.fixed_corruptions:
r = self.get_rand()
img, undo_fn = self.apply_corruption(img, aug, r, applied_augs)
entropy.append(r)
if undo_fn is not None:
undo_fns.append(undo_fn)
# Apply undo_fns after all corruptions are finished, in same order.
for ufn in undo_fns:
img = ufn(img)
corrupted_imgs.append(img)
if return_entropy:
return corrupted_imgs, entropy
else:
return corrupted_imgs
def apply_corruption(self, img, aug, rand_val, applied_augmentations):
undo_fn = None
if 'color_quantization' in aug:
# Color quantization
quant_div = 2 ** (int(rand_val * 10 / 3) + 2)
img = img * 255
img = (img // quant_div) * quant_div
img = img / 255
elif 'color_jitter' in aug:
lo_end = 0
hi_end = .2
setting = rand_val * (hi_end - lo_end) + lo_end
img = kornia_color_jitter_numpy(img, setting)
elif 'gaussian_blur' in aug:
img = cv2.GaussianBlur(img, (0,0), self.blur_scale*rand_val*1.5)
elif 'motion_blur' in aug:
# Motion blur
intensity = self.blur_scale*rand_val * 3 + 1
angle = random.randint(0,360)
k = np.zeros((intensity, intensity), dtype=np.float32)
k[(intensity - 1) // 2, :] = np.ones(intensity, dtype=np.float32)
k = cv2.warpAffine(k, cv2.getRotationMatrix2D((intensity / 2 - 0.5, intensity / 2 - 0.5), angle, 1.0),
(intensity, intensity))
k = k * (1.0 / np.sum(k))
img = cv2.filter2D(img, -1, k)
elif 'block_noise' in aug:
# Large distortion blocks in part of an img, such as is used to mask out a face.
pass
elif 'lq_resampling' in aug:
# Random mode interpolation HR->LR->HR
if 'lq_resampling4x' == aug:
scale = 4
else:
if rand_val < .3:
scale = 1
elif rand_val < .7:
scale = 2
else:
scale = 4
if scale > 1:
interpolation_modes = [cv2.INTER_NEAREST, cv2.INTER_CUBIC, cv2.INTER_LINEAR, cv2.INTER_LANCZOS4]
mode = random.randint(0,4) % len(interpolation_modes)
# Downsample first, then upsample using the random mode.
img = cv2.resize(img, dsize=(img.shape[1]//scale, img.shape[0]//scale), interpolation=mode)
def lq_resampling_undo_fn(scale, img):
return cv2.resize(img, dsize=(img.shape[1]*scale, img.shape[0]*scale), interpolation=cv2.INTER_LINEAR)
undo_fn = functools.partial(lq_resampling_undo_fn, scale)
elif 'color_shift' in aug:
# Color shift
pass
elif 'interlacing' in aug:
# Interlacing distortion
pass
elif 'chromatic_aberration' in aug:
# Chromatic aberration
pass
elif 'noise' in aug:
# Random noise
if 'noise-5' == aug:
noise_intensity = 5 / 255.0
else:
noise_intensity = (rand_val*6) / 255.0
img += np.random.rand(*img.shape) * noise_intensity
elif 'jpeg' in aug:
if 'noise' not in applied_augmentations and 'noise-5' not in applied_augmentations:
if aug == 'jpeg':
lo=10
range=20
elif aug == 'jpeg-low':
lo=15
range=10
elif aug == 'jpeg-medium':
lo=23
range=25
elif aug == 'jpeg-broad':
lo=15
range=60
elif aug == 'jpeg-normal':
lo=47
range=35
else:
raise NotImplementedError("specified jpeg corruption doesn't exist")
# JPEG compression
qf = (int((1-rand_val)*range) + lo)
# Use PIL to perform a mock compression to a data buffer, then swap back to cv2.
img = (img * 255).astype(np.uint8)
img = Image.fromarray(img)
buffer = BytesIO()
img.save(buffer, "JPEG", quality=qf, optimize=True)
buffer.seek(0)
jpeg_img_bytes = np.asarray(bytearray(buffer.read()), dtype="uint8")
img = read_img("buffer", jpeg_img_bytes, rgb=True)
elif 'saturation' in aug:
# Lightening / saturation
saturation = rand_val * .3
img = np.clip(img + saturation, a_max=1, a_min=0)
elif 'greyscale' in aug:
img = np.tile(np.mean(img, axis=2, keepdims=True), [1,1,3])
elif 'none' not in aug:
raise NotImplementedError("Augmentation doesn't exist")
return img, undo_fn
| [
"numpy.mean",
"numpy.ones",
"numpy.clip",
"torch.from_numpy",
"numpy.random.rand",
"numpy.zeros",
"numpy.sum"
] | [(47, 'utils.util.opt_get', 'opt_get', (['opt', "['cosine_bias']", '(True)'], {}), False, 'from utils.util import opt_get\n'), (33, 'kornia.augmentation.ColorJitter', 'ColorJitter', (['setting', 'setting', 'setting', 'setting'], {}), False, 'from kornia.augmentation import ColorJitter\n'), (55, 'random.Random', 'random.Random', (["self.opt['random_seed']"], {}), False, 'import random\n'), (57, 'random.Random', 'random.Random', ([], {}), False, 'import random\n'), (78, 'random.choices', 'random.choices', (['self.random_corruptions'], {'k': 'self.num_corrupts'}), False, 'import random\n'), (64, 'math.cos', 'cos', (['(r * pi / 2)'], {}), False, 'from math import cos, pi\n'), (122, 'cv2.GaussianBlur', 'cv2.GaussianBlur', (['img', '(0, 0)', '(self.blur_scale * rand_val * 1.5)'], {}), False, 'import cv2\n'), (32, 'torch.from_numpy', 'torch.from_numpy', (['img'], {}), False, 'import torch\n'), (126, 'random.randint', 'random.randint', (['(0)', '(360)'], {}), False, 'import random\n'), (127, 'numpy.zeros', 'np.zeros', (['(intensity, intensity)'], {'dtype': 'np.float32'}), True, 'import numpy as np\n'), (128, 'numpy.ones', 'np.ones', (['intensity'], {'dtype': 'np.float32'}), True, 'import numpy as np\n'), (132, 'cv2.filter2D', 'cv2.filter2D', (['img', '(-1)', 'k'], {}), False, 'import cv2\n'), (129, 'cv2.getRotationMatrix2D', 'cv2.getRotationMatrix2D', (['(intensity / 2 - 0.5, intensity / 2 - 0.5)', 'angle', '(1.0)'], {}), False, 'import cv2\n'), (131, 'numpy.sum', 'np.sum', (['k'], {}), True, 'import numpy as np\n'), (151, 'cv2.resize', 'cv2.resize', (['img'], {'dsize': '(img.shape[1] // scale, img.shape[0] // scale)', 'interpolation': 'mode'}), False, 'import cv2\n'), (154, 'functools.partial', 'functools.partial', (['lq_resampling_undo_fn', 'scale'], {}), False, 'import functools\n'), (149, 'random.randint', 'random.randint', (['(0)', '(4)'], {}), False, 'import random\n'), (153, 'cv2.resize', 'cv2.resize', (['img'], {'dsize': '(img.shape[1] * scale, img.shape[0] * scale)', 'interpolation': 'cv2.INTER_LINEAR'}), False, 'import cv2\n'), (170, 'numpy.random.rand', 'np.random.rand', (['*img.shape'], {}), True, 'import numpy as np\n'), (194, 'PIL.Image.fromarray', 'Image.fromarray', (['img'], {}), False, 'from PIL import Image\n'), (195, 'io.BytesIO', 'BytesIO', ([], {}), False, 'from io import BytesIO\n'), (199, 'data.util.read_img', 'read_img', (['"""buffer"""', 'jpeg_img_bytes'], {'rgb': '(True)'}), False, 'from data.util import read_img\n'), (203, 'numpy.clip', 'np.clip', (['(img + saturation)'], {'a_max': '(1)', 'a_min': '(0)'}), True, 'import numpy as np\n'), (205, 'numpy.mean', 'np.mean', (['img'], {'axis': '(2)', 'keepdims': '(True)'}), True, 'import numpy as np\n')] |
pclucas14/continuum | 09034db1371e9646ca660fd4d4df73e61bf77067 | tests/test_background_swap.py | import os
from torch.utils.data import DataLoader
from continuum.datasets import CIFAR10, InMemoryDataset
from continuum.datasets import MNIST
import torchvision
from continuum.scenarios import TransformationIncremental
import pytest
import numpy as np
from continuum.transforms.bg_swap import BackgroundSwap
DATA_PATH = os.environ.get("CONTINUUM_DATA_PATH")
# Uncomment for debugging via image output
# import matplotlib.pyplot as plt
def test_bg_swap_fast():
"""
Fast test for background swap.
"""
bg_x = np.ones(shape=[2, 5, 5, 3]) * -1
bg_y = np.random.rand(2)
fg = np.random.normal(loc=.5, scale=.1, size=[5, 5])
bg = InMemoryDataset(bg_x, bg_y)
bg_swap = BackgroundSwap(bg, input_dim=(5, 5), normalize_bg=None)
spliced_1_channel = bg_swap(fg)[:, :, 0]
assert np.array_equal((spliced_1_channel <= -1), (fg <= .5))
@pytest.mark.slow
def test_background_swap_numpy():
"""
Test background swap on a single ndarray input.
"""
mnist = MNIST(DATA_PATH, download=True, train=True)
cifar = CIFAR10(DATA_PATH, download=True, train=True)
bg_swap = BackgroundSwap(cifar, input_dim=(28, 28))
im = mnist.get_data()[0][0]
im = bg_swap(im)
# Uncomment for debugging
# plt.imshow(im, interpolation='nearest')
# plt.show()
@pytest.mark.slow
def test_background_swap_torch():
"""
Test background swap on a single tensor input.
"""
cifar = CIFAR10(DATA_PATH, download=True, train=True)
mnist = torchvision.datasets.MNIST(DATA_PATH, train=True, download=True,
transform=torchvision.transforms.Compose([
torchvision.transforms.ToTensor()
]))
bg_swap = BackgroundSwap(cifar, input_dim=(28, 28))
im = mnist[0][0]
im = bg_swap(im)
# Uncomment for debugging
# plt.imshow(im.permute(1, 2, 0), interpolation='nearest')
# plt.show()
@pytest.mark.slow
def test_background_tranformation():
"""
Example code using TransformationIncremental to create a setting with 3 tasks.
"""
cifar = CIFAR10(DATA_PATH, train=True)
mnist = MNIST(DATA_PATH, download=False, train=True)
nb_task = 3
list_trsf = []
for i in range(nb_task):
list_trsf.append([torchvision.transforms.ToTensor(), BackgroundSwap(cifar, bg_label=i, input_dim=(28, 28)),
torchvision.transforms.ToPILImage()])
scenario = TransformationIncremental(mnist, base_transformations=[torchvision.transforms.ToTensor()],
incremental_transformations=list_trsf)
folder = "tests/samples/background_trsf/"
if not os.path.exists(folder):
os.makedirs(folder)
for task_id, task_data in enumerate(scenario):
task_data.plot(path=folder, title=f"background_{task_id}.jpg", nb_samples=100, shape=[28, 28, 3])
loader = DataLoader(task_data)
_, _, _ = next(iter(loader))
| [
"numpy.array_equal",
"numpy.ones",
"torch.utils.data.DataLoader",
"numpy.random.normal",
"numpy.random.rand"
] | [(13, 'os.environ.get', 'os.environ.get', (['"""CONTINUUM_DATA_PATH"""'], {}), False, 'import os\n'), (24, 'numpy.random.rand', 'np.random.rand', (['(2)'], {}), True, 'import numpy as np\n'), (26, 'numpy.random.normal', 'np.random.normal', ([], {'loc': '(0.5)', 'scale': '(0.1)', 'size': '[5, 5]'}), True, 'import numpy as np\n'), (27, 'continuum.datasets.InMemoryDataset', 'InMemoryDataset', (['bg_x', 'bg_y'], {}), False, 'from continuum.datasets import CIFAR10, InMemoryDataset\n'), (29, 'continuum.transforms.bg_swap.BackgroundSwap', 'BackgroundSwap', (['bg'], {'input_dim': '(5, 5)', 'normalize_bg': 'None'}), False, 'from continuum.transforms.bg_swap import BackgroundSwap\n'), (33, 'numpy.array_equal', 'np.array_equal', (['(spliced_1_channel <= -1)', '(fg <= 0.5)'], {}), True, 'import numpy as np\n'), (41, 'continuum.datasets.MNIST', 'MNIST', (['DATA_PATH'], {'download': '(True)', 'train': '(True)'}), False, 'from continuum.datasets import MNIST\n'), (42, 'continuum.datasets.CIFAR10', 'CIFAR10', (['DATA_PATH'], {'download': '(True)', 'train': '(True)'}), False, 'from continuum.datasets import CIFAR10, InMemoryDataset\n'), (44, 'continuum.transforms.bg_swap.BackgroundSwap', 'BackgroundSwap', (['cifar'], {'input_dim': '(28, 28)'}), False, 'from continuum.transforms.bg_swap import BackgroundSwap\n'), (59, 'continuum.datasets.CIFAR10', 'CIFAR10', (['DATA_PATH'], {'download': '(True)', 'train': '(True)'}), False, 'from continuum.datasets import CIFAR10, InMemoryDataset\n'), (66, 'continuum.transforms.bg_swap.BackgroundSwap', 'BackgroundSwap', (['cifar'], {'input_dim': '(28, 28)'}), False, 'from continuum.transforms.bg_swap import BackgroundSwap\n'), (81, 'continuum.datasets.CIFAR10', 'CIFAR10', (['DATA_PATH'], {'train': '(True)'}), False, 'from continuum.datasets import CIFAR10, InMemoryDataset\n'), (82, 'continuum.datasets.MNIST', 'MNIST', (['DATA_PATH'], {'download': '(False)', 'train': '(True)'}), False, 'from continuum.datasets import MNIST\n'), (23, 'numpy.ones', 'np.ones', ([], {'shape': '[2, 5, 5, 3]'}), True, 'import numpy as np\n'), (91, 'os.path.exists', 'os.path.exists', (['folder'], {}), False, 'import os\n'), (92, 'os.makedirs', 'os.makedirs', (['folder'], {}), False, 'import os\n'), (95, 'torch.utils.data.DataLoader', 'DataLoader', (['task_data'], {}), False, 'from torch.utils.data import DataLoader\n'), (86, 'torchvision.transforms.ToTensor', 'torchvision.transforms.ToTensor', ([], {}), False, 'import torchvision\n'), (86, 'continuum.transforms.bg_swap.BackgroundSwap', 'BackgroundSwap', (['cifar'], {'bg_label': 'i', 'input_dim': '(28, 28)'}), False, 'from continuum.transforms.bg_swap import BackgroundSwap\n'), (87, 'torchvision.transforms.ToPILImage', 'torchvision.transforms.ToPILImage', ([], {}), False, 'import torchvision\n'), (88, 'torchvision.transforms.ToTensor', 'torchvision.transforms.ToTensor', ([], {}), False, 'import torchvision\n'), (63, 'torchvision.transforms.ToTensor', 'torchvision.transforms.ToTensor', ([], {}), False, 'import torchvision\n')] |
g-nightingale/tox_examples | d7714375c764580b4b8af9db61332ced4e851def | packaging/squarer/ml_squarer.py | import numpy as np
def train_ml_squarer() -> None:
print("Training!")
def square() -> int:
"""Square a number...maybe"""
return np.random.randint(1, 100)
if __name__ == '__main__':
train_ml_squarer() | [
"numpy.random.randint"
] | [(10, 'numpy.random.randint', 'np.random.randint', (['(1)', '(100)'], {}), True, 'import numpy as np\n')] |
README.md exists but content is empty.
- Downloads last month
- 26