Here are the examples of the python api numpy.random.seed taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
15455 Examples
3
Source : train_test.py
with MIT License
from 1024210879
with MIT License
from 1024210879
def create_mock_dataset(dataset_dir, image_size):
nrof_persons = 3
nrof_images_per_person = 2
np.random.seed(seed=666)
os.mkdir(dataset_dir)
for i in range(nrof_persons):
class_name = '%04d' % (i+1)
class_dir = os.path.join(dataset_dir, class_name)
os.mkdir(class_dir)
for j in range(nrof_images_per_person):
img_name = '%04d' % (j+1)
img_path = os.path.join(class_dir, class_name+'_'+img_name + '.png')
img = np.random.uniform(low=0.0, high=255.0, size=(image_size,image_size,3))
cv2.imwrite(img_path, img) #@UndefinedVariable
# Create a mock LFW pairs file
def create_mock_lfw_pairs(tmp_dir):
3
Source : main.py
with MIT License
from 1Konny
with MIT License
from 1Konny
def main(args):
seed = args.seed
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
np.random.seed(seed)
net = Solver(args)
if args.train:
net.train()
else:
net.traverse()
if __name__ == "__main__":
3
Source : trainer.py
with MIT License
from 2han9x1a0release
with MIT License
from 2han9x1a0release
def setup_env():
"""Sets up environment for training or testing."""
if dist.is_master_proc():
# Ensure that the output dir exists
os.makedirs(cfg.OUT_DIR, exist_ok=True)
# Save the config
config.dump_cfg()
# Setup logging
logging.setup_logging()
# Log the config
logger.info("Config:\n{}".format(cfg))
# Fix the RNG seeds (see RNG comment in core/config.py for discussion)
np.random.seed(cfg.RNG_SEED)
torch.manual_seed(cfg.RNG_SEED)
# Configure the CUDNN backend
torch.backends.cudnn.benchmark = cfg.CUDNN.BENCHMARK
def setup_model():
3
Source : eval_retrieval.py
with MIT License
from 3dlg-hcvc
with MIT License
from 3dlg-hcvc
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--dataset', help='dataset (''shapenet'', ''primitives'')', default='shapenet')
parser.add_argument('--embeddings_path', help='path to text embeddings pickle file', default='./logs/retrieval/v64i128b128/Nov12_05-26-10-2/test/output.p')
parser.add_argument('--metric', help='path to text embeddings pickle file', default='cosine',
type=str)
args = parser.parse_args()
with open(args.embeddings_path, 'rb') as f:
embeddings_dict = pickle.load(f)
render_dir = os.path.join(os.path.dirname(args.embeddings_path), 'nearest_neighbor_renderings')
np.random.seed(1234)
info = "../data/text2shape-data/shapenet/shapenet.json"
compute_metrics(info, args.dataset, embeddings_dict, os.path.dirname(args.embeddings_path), metric=args.metric, concise=render_dir)
if __name__ == '__main__':
3
Source : eval_retrieval_s2t.py
with MIT License
from 3dlg-hcvc
with MIT License
from 3dlg-hcvc
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--dataset', help='dataset (''shapenet'', ''primitives'')', default='shapenet')
parser.add_argument('--embeddings_path', help='path to text embeddings pickle file', default='logs/retrieval/v64i128b128/Nov12_05-26-10-2/test/output.p')
parser.add_argument('--metric', help='path to text embeddings pickle file', default='cosine',
type=str)
args = parser.parse_args()
with open(args.embeddings_path, 'rb') as f:
embeddings_dict = pickle.load(f)
render_dir = os.path.join(os.path.dirname(args.embeddings_path), 'nearest_neighbor_renderings')
np.random.seed(1234)
info = "../data/text2shape-data/shapenet/shapenet.json"
compute_metrics(info, args.dataset, embeddings_dict, os.path.dirname(args.embeddings_path), metric=args.metric, concise=render_dir)
if __name__ == '__main__':
3
Source : seed.py
with Apache License 2.0
from 920232796
with Apache License 2.0
from 920232796
def set_seed(seed: int):
"""
Helper function for reproducible behavior to set the seed in ``random``, ``numpy``, ``torch`` and/or ``tf`` (if
installed).
Args:
seed (:obj:`int`): The seed to set.
"""
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
3
Source : linearity_hypothesis.py
with MIT License
from 95616ARG
with MIT License
from 95616ARG
def random_perturbation(self, image, l_inf, seed):
"""Returns a randomly-perturbed version of @image.
@seed should be based on the image itself so that all networks get the
same random images.
"""
np.random.seed(seed)
signs = np.sign(np.random.choice([-1, 1], image.shape))
return self.perturb_l_inf(image, signs, l_inf)
@staticmethod
3
Source : eval_pretrained_model.py
with MIT License
from 983632847
with MIT License
from 983632847
def set_seed(seed=1):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
def main():
3
Source : function.py
with BSD 3-Clause "New" or "Revised" License
from a3794110
with BSD 3-Clause "New" or "Revised" License
from a3794110
def Create_Vehicle (Vehicle , VehilceDensity) :
global CurVehNum
np.random.seed()
EnterVehNum = int(np.random.poisson(VehilceDensity, 1)) # λ=1 k=VehilceDensity
# CurVehNum = len(Vehicle) # current vehicle number
if EnterVehNum > 0:
for i in range(CurVehNum, CurVehNum + EnterVehNum):
# Vehicle.append(On_Board_Unit())
traci.vehicle.addFull(str(i),'routedist1',typeID='typedist1')
CurVehNum = CurVehNum + EnterVehNum # current vehicle number
return Vehicle
def Vehicle_Enter_Network(DepartVeh,Vehicle):
3
Source : Parameter.py
with BSD 3-Clause "New" or "Revised" License
from a3794110
with BSD 3-Clause "New" or "Revised" License
from a3794110
def Caculate_Current_Battery_Capacity(self):
np.random.seed()
self.Mass = traci.vehicle.setParameter(self.VehId, "device.battery.vehicleMass", '1521') #將車重改為1521KG (Nissan Leaf)
# self.frontSurfaceArea = traci.vehicle.setParameter (self.VehId,"device.battery.frontSurfaceArea",'2.65') #迎風面積改為2.65
# self.airDragCoefficient = traci.vehicle.setParameter (self.VehId,"device.battery.airDragCoefficient",'0.32') #空氣阻力係數0.32
# self.rollDragCoefficient = traci.vehicle.setParameter(self.VehId,"device.battery.rollDragCoefficient", '0.015') #滾動阻力係數0.015
# self.recuperationEfficiency = traci.vehicle.setParameter(self.VehId,"device.battery.recuperationEfficiency",'0.9') #傳動效率 0.9
self.BatteryConsume = float(traci.vehicle.getParameter(self.VehId,"device.battery.energyConsumed"))
self.CurrentBatteryCapacity = self.CurrentBatteryCapacity - self.BatteryConsume
self.BatteryPercent = (self.CurrentBatteryCapacity / self.MaxBatteryCapacity) * 100
class Charging_Station_Information():
3
Source : dataset_loader.py
with MIT License
from AaltoML
with MIT License
from AaltoML
def __init__(self, root, seed=None, train=True, sequence_length=3,transform=None, target_transform=None):
np.random.seed(seed)
random.seed(seed)
self.root = Path(root)
scene_list_path = self.root / 'train_wo_gtav.txt' if train else self.root / 'val.txt'
self.scenes = [self.root / folder[:-1] for folder in open(scene_list_path)]
self.samples = crawl_folders(self.scenes, sequence_length)
self.transform = transform
def __getitem__(self, index):
3
Source : utils.py
with MIT License
from AaltoML
with MIT License
from AaltoML
def train_test_split_indices(N, split=0.5, seed=0):
np.random.seed(seed)
rand_index = np.random.permutation(N)
N_tr = int(N * split)
return rand_index[:N_tr], rand_index[N_tr:]
def lat_lon_to_polygon_buffer(row, actual_bin_sizes):
3
Source : ppbo_numerical_main.py
with MIT License
from AaltoPML
with MIT License
from AaltoPML
def six_hump_camel(traj):
PPBO_settings_ = PPBO_settings(D=2,bounds=((-3,3),(-2,2)),
xi_acquisition_function=traj.xi_acquisition_function,m=traj.m,
theta_initial=[0.01,0.26,0.1],alpha_grid_distribution='equispaced') #[0.01,0.26,0.1],[1,0.1,8]
np.random.seed(traj.initialization_seed)
initial_queries_xi = np.diag([PPBO_settings_.original_bounds[i][1] for i in range(PPBO_settings_.D)])
#initial_queries_x = np.random.uniform([PPBO_settings_.original_bounds[i][0] for i in range(PPBO_settings_.D)], [PPBO_settings_.original_bounds[i][1] for i in range(PPBO_settings_.D)], (len(initial_queries_xi), PPBO_settings_.D))
''' Initial values = all cornes of the domain X '''
initial_queries_xi = np.tile(initial_queries_xi,(2,1))
initial_queries_x = hypercube_corners(PPBO_settings_.original_bounds)[0:len(initial_queries_xi)]
results,xstar_results,mustar_results,GP_model = run_ppbo_loop('six_hump_camel',initial_queries_xi,initial_queries_x,traj.number_of_actual_queries,PPBO_settings_)
traj.f_add_result('xstar',xstar_results)
traj.f_add_result('mustar',mustar_results)
return GP_model
def levy(traj):
3
Source : utils.py
with MIT License
from aangelopoulos
with MIT License
from aangelopoulos
def fix_randomness(seed=0):
np.random.seed(seed=seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
random.seed(seed)
def get_cifar10_classes():
3
Source : finetune.py
with MIT License
from aangelopoulos
with MIT License
from aangelopoulos
def fix_randomness(seed):
### Fix randomness
np.random.seed(seed=seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
random.seed(seed)
if __name__ == "__main__":
3
Source : utils.py
with MIT License
from aangelopoulos
with MIT License
from aangelopoulos
def fix_randomness(seed=0):
np.random.seed(seed=seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
random.seed(seed)
def get_imagenet_classes():
3
Source : utils.py
with MIT License
from aangelopoulos
with MIT License
from aangelopoulos
def fix_randomness(seed):
np.random.seed(seed=seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
random.seed(seed)
# Computes logits and targets from a model and loader
def get_scores_targets(model, loader, corr):
3
Source : polyp_utils.py
with MIT License
from aangelopoulos
with MIT License
from aangelopoulos
def fix_randomness(seed=0):
np.random.seed(seed=seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
random.seed(seed)
"""
3
Source : load_kitti_annotations.py
with MIT License
from abbyxxn
with MIT License
from abbyxxn
def split_dataset_function(self, image_index, factor=0.8):
image_ind = []
for image in image_index:
image_ind.append(image.split('_')[0])
np.random.seed()
np.random.shuffle(image_ind)
train_count = (len(image_ind) * int(factor * 100)) // 100
train = image_ind[:train_count]
val = image_ind[train_count:]
return val, train
def _get_default_data_path(self):
3
Source : data_utils.py
with MIT License
from abeja-inc
with MIT License
from abeja-inc
def init_pool_generator(gens, random_seed=None):
global _SHARED_SEQUENCES
_SHARED_SEQUENCES = gens
if random_seed is not None:
ident = mp.current_process().ident
np.random.seed(random_seed + ident)
def next_sample(uid):
3
Source : utils.py
with MIT License
from AberHu
with MIT License
from AberHu
def set_seed(seed):
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
class AverageMeter(object):
3
Source : train_eval.py
with MIT License
from AberHu
with MIT License
from AberHu
def set_seed(seed):
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
def main():
3
Source : engine.py
with MIT License
from abhinavkashyap
with MIT License
from abhinavkashyap
def _set_seeds(self):
seed = self.seeds.get("random_seed", 17290)
numpy_seed = self.seeds.get("numpy_seed", 1729)
torch_seed = self.seeds.get("pytorch_seed", 172)
if seed is not None:
random.seed(seed)
if numpy_seed is not None:
np.random.seed(numpy_seed)
if torch_seed is not None:
torch.manual_seed(torch_seed)
# Seed all GPUs with the same seed if available.
if torch.cuda.is_available():
torch.cuda.manual_seed_all(torch_seed)
3
Source : train.py
with Apache License 2.0
from abhishekkrthakur
with Apache License 2.0
from abhishekkrthakur
def seed_everything(seed: int) -> None:
random.seed(seed)
os.environ["PYTHONHASHSEED"] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = True
def parse_args():
3
Source : train.py
with MIT License
from abhishekkrthakur
with MIT License
from abhishekkrthakur
def seed_everything(seed: int):
random.seed(seed)
os.environ["PYTHONHASHSEED"] = str(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = True
def parse_args():
3
Source : test_IO_rtf.py
with Apache License 2.0
from abhiTronix
with Apache License 2.0
from abhiTronix
def test_invalid_params_rtf(format):
"""
Invalid parameter Failure Test - Made to fail by calling invalid parameters
"""
np.random.seed(0)
# generate random data for 10 frames
random_data = np.random.random(size=(480, 640, 3)) * 255
input_data = random_data.astype(np.uint8)
stream_params = {"-vcodec": "unknown"}
streamer = StreamGear(
output="output{}".format(".mpd" if format == "dash" else ".m3u8"),
format=format,
logging=True,
**stream_params
)
streamer.stream(input_data)
streamer.stream(input_data)
streamer.terminate()
3
Source : picamera.py
with Apache License 2.0
from abhiTronix
with Apache License 2.0
from abhiTronix
def array_data(self, size, frame_num=10):
"""
Generate 10 numpy frames with random pixels
"""
np.random.seed(0)
random_data = np.random.random(size=(frame_num, size[0], size[1], 3)) * 255
return random_data.astype(np.uint8)
def capture_continuous(
3
Source : test_IO.py
with Apache License 2.0
from abhiTronix
with Apache License 2.0
from abhiTronix
def test_failedextension():
"""
IO Test - made to fail with filename with wrong extention
"""
np.random.seed(0)
# generate random data for 10 frames
random_data = np.random.random(size=(10, 480, 640, 3)) * 255
input_data = random_data.astype(np.uint8)
# 'garbage' extension does not exist
with pytest.raises(ValueError):
writer = WriteGear("garbage.garbage", logging=True)
writer.write(input_data)
writer.close()
@pytest.mark.xfail(raises=ValueError)
3
Source : test_IO.py
with Apache License 2.0
from abhiTronix
with Apache License 2.0
from abhiTronix
def test_invalid_encoder(v_codec):
"""
Invalid encoder Failure Test
"""
np.random.seed(0)
# generate random data for 10 frames
random_data = np.random.random(size=(480, 640, 3)) * 255
input_data = random_data.astype(np.uint8)
try:
output_params = {"-vcodec": v_codec}
writer = WriteGear(
"output.mp4", compression_mode=True, logging=True, **output_params
)
writer.write(input_data)
writer.write(input_data)
writer.close()
except Exception as e:
pytest.fail(str(e))
3
Source : perturbation_attack.py
with MIT License
from abojchevski
with MIT License
from abojchevski
def baseline_random_top_flips(candidates, n_flips, seed):
"""Selects (n_flips) number of flips at random.
:param candidates: np.ndarray, shape [?, 2]
Candidate set of edge flips
:param n_flips: int
Number of flips to select
:param seed: int
Random seed
:return: np.ndarray, shape [?, 2]
The top edge flips from the candidate set
"""
np.random.seed(seed)
return candidates[np.random.permutation(len(candidates))[:n_flips]]
def baseline_eigencentrality_top_flips(adj_matrix, candidates, n_flips):
3
Source : optimization.py
with GNU General Public License v3.0
from acamero
with GNU General Public License v3.0
from acamero
def __init__(self,
problem,
seed=None,
verbose=0):
if seed is not None:
np.random.seed(seed)
rd.seed(seed)
tf.random.set_seed(seed)
if not isinstance(problem,
Problem):
raise Exception("A valid problem must be provided")
self.problem = problem
self.verbose = verbose
@abstractmethod
3
Source : sampling.py
with GNU General Public License v3.0
from acamero
with GNU General Public License v3.0
from acamero
def __init__(self,
seed=None):
if seed is not None:
np.random.seed(seed)
rd.seed(seed)
tf.random.set_seed(seed)
def sample(self,
3
Source : optimizer.py
with GNU General Public License v3.0
from acamero
with GNU General Public License v3.0
from acamero
def __init__(self, data, config, cache, seed=1234):
if not self._validate_config(config):
print('The configuration is not valid')
raise
if config.blind:
self.data = data
else:
self.data = pd.concat([data['train'],data['test']])
print("Testing and training data merged")
self.config = config
self.cache = cache
self.layer_in = len(config.x_features)
self.layer_out = len(config.y_features)
np.random.seed(seed)
rd.seed(seed)
tf.set_random_seed(seed)
self.memory_tracker = tracker.SummaryTracker()
@abstractmethod
3
Source : sample-arch.py
with GNU General Public License v3.0
from acamero
with GNU General Public License v3.0
from acamero
def __init__(self, data, config, seed=1234):
if not self._validate_config(config):
print('The configuration is not valid')
raise
if config.merge_data:
self.data = pd.concat([data['train'],data['test']])
print("Testing and training data merged")
else:
self.data = data['test']
self.config = config
self.layer_in = len(config.x_features)
self.layer_out = len(config.y_features)
np.random.seed(seed)
rd.seed(seed)
tf.set_random_seed(seed)
self.output_file = config.results_folder + config.config_name + '-' + str(seed) + '-sol.csv'
def _validate_config(self, config):
3
Source : optimizer.py
with GNU General Public License v3.0
from acamero
with GNU General Public License v3.0
from acamero
def __init__(self, data_dict, config, cache, seed=1234):
if not self._validate_config(config):
print('The configuration is not valid')
raise
self.cache = cache
self.data_dict = data_dict
self.config = config
self.layer_in = len(config.x_features)
self.layer_out = len(config.y_features)
self.min_delta = config.min_delta
self.patience = config.patience
np.random.seed(seed)
rd.seed(seed)
tf.set_random_seed(seed)
@abstractmethod
3
Source : __init__.py
with Apache License 2.0
from Accenture
with Apache License 2.0
from Accenture
def seed(seed):
""" fix random seeds to minimize random variance """
random.seed(seed)
np.random.seed(seed)
tf.compat.v1.set_random_seed(seed)
def optimize_tf_parallel_processing(num_par_exec_units, config=None, gpu_id=None):
3
Source : builder.py
with Apache License 2.0
from achao2013
with Apache License 2.0
from achao2013
def worker_init_fn(worker_id, num_workers, rank, seed):
# The seed of each worker equals to
# num_worker * rank + worker_id + user_seed
worker_seed = num_workers * rank + worker_id + seed
np.random.seed(worker_seed)
random.seed(worker_seed)
3
Source : edge.py
with MIT License
from acids-ircam
with MIT License
from acids-ircam
def find_knn(A,d):
np.random.seed(3334)
#np.random.seed()
#np.random.seed(seed=int(time.time()))
r = 500
# random samples from A
A = A.reshape((-1,1))
N = A.shape[0]
k=math.floor(0.43*N**(2/3 + 0.17*(d/(d+1)) )*math.exp(-1.0/np.max([10000, d**4])))
#print('k,d', k, d)
T= np.random.choice(A.reshape(-1,), size=r).reshape(-1,1)
nbrs = NearestNeighbors(n_neighbors=k, algorithm='auto').fit(A)
distances, indices = nbrs.kneighbors(T)
d = np.mean(distances[:,-1])
return d
# Returns epsilon and random shifts b
def gen_eps(XW,YV):
3
Source : misc_util.py
with MIT License
from AcutronicRobotics
with MIT License
from AcutronicRobotics
def set_global_seeds(i):
try:
import MPI
rank = MPI.COMM_WORLD.Get_rank()
except ImportError:
rank = 0
myseed = i + 1000 * rank if i is not None else None
try:
import tensorflow as tf
tf.set_random_seed(myseed)
except ImportError:
pass
np.random.seed(myseed)
random.seed(myseed)
def pretty_eta(seconds_left):
3
Source : test_vec_env.py
with MIT License
from AcutronicRobotics
with MIT License
from AcutronicRobotics
def __init__(self, seed, shape, dtype):
np.random.seed(seed)
self._dtype = dtype
self._start_obs = np.array(np.random.randint(0, 0x100, size=shape),
dtype=dtype)
self._max_steps = seed + 1
self._cur_obs = None
self._cur_step = 0
# this is 0xFF instead of 0x100 because the Box space includes
# the high end, while randint does not
self.action_space = gym.spaces.Box(low=0, high=0xFF, shape=shape, dtype=dtype)
self.observation_space = self.action_space
def step(self, action):
3
Source : format_fastmri.py
with Apache License 2.0
from ad12
with Apache License 2.0
from ad12
def seed_everything(device=None):
np.random.seed(SEED)
torch.manual_seed(SEED)
torch.cuda.manual_seed_all(SEED)
random.seed(SEED)
if cp is not None:
cp.random.seed(SEED)
if device is not None:
if isinstance(device, int):
device = sp.Device(device)
with device:
device.xp.random.seed(SEED)
def is_valid_file(fpath):
3
Source : test_subsample.py
with Apache License 2.0
from ad12
with Apache License 2.0
from ad12
def test_random1d_randomness(acc, cf, shape, seed):
np.random.seed(seed)
shape = (1, *shape)
a = RandomMaskFunc1D(acc, center_fractions=(cf,))
seeds = np.random.randint(0, 2 ** 32, size=100)
a_mask = a(shape, seed=seed, acceleration=acc)
for s in seeds:
a_mask2 = a(shape, seed=s, acceleration=acc)
if torch.any(a_mask != a_mask2):
return
assert False
3
Source : preprocess.py
with MIT License
from AdaCompNUS
with MIT License
from AdaCompNUS
def reset_state(self):
""" Reset state. Fix numpy random seed if needed."""
super(House3DTrajData, self).reset_state()
if self.seed is not None:
np.random.seed(1)
else:
np.random.seed(self.rng.randint(0, 99999999))
def get_data(self):
3
Source : run.py
with GNU General Public License v3.0
from AdamStelmaszczyk
with GNU General Public License v3.0
from AdamStelmaszczyk
def set_seed(env, seed):
random.seed(seed)
np.random.seed(seed)
tf.set_random_seed(seed)
env.seed(seed)
def print_weights(model):
3
Source : run.py
with MIT License
from AdamStelmaszczyk
with MIT License
from AdamStelmaszczyk
def set_seed(env, seed):
random.seed(seed)
np.random.seed(seed)
tf.set_random_seed(seed)
env.seed(seed)
def main(args):
3
Source : trainer.py
with MIT License
from Adapter-Hub
with MIT License
from Adapter-Hub
def set_seed(seed: int):
if seed is None:
seed = int((time.time() * 1000) % 2 ** 32)
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
return seed
def _pad_and_concatenate(array1, array2, padding_index=-100):
3
Source : detector.py
with MIT License
from adipandas
with MIT License
from adipandas
def __init__(self, object_names, confidence_threshold, nms_threshold, draw_bboxes=True):
self.object_names = object_names
self.confidence_threshold = confidence_threshold
self.nms_threshold = nms_threshold
self.height = None
self.width = None
np.random.seed(12345)
if draw_bboxes:
self.bbox_colors = {key: np.random.randint(0, 255, size=(3,)).tolist() for key in self.object_names.keys()}
def forward(self, image):
3
Source : plot_ap.py
with MIT License
from adithyamurali
with MIT License
from adithyamurali
def get_ap_random(n_seeds, labels):
aps = []
N = len(labels)
for i in range(n_seeds):
np.random.seed(i)
random_probs = np.random.uniform(low=0, high=1, size=(N)).tolist()
ap = average_precision_score(labels, random_probs)
aps.append(ap)
return np.mean(aps)
def draw_plot(dictionary, dictionary_random, n_elems, window_title, plot_title, x_label, output_path, to_show, plot_color, mAP_random=None):
3
Source : utils.py
with MIT License
from aditimavalankar
with MIT License
from aditimavalankar
def set_global_seed(seed):
np.random.seed(seed)
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
random.seed(seed)
def update(h, s_next, food_type, device):
3
Source : test_random.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_in_bounds_fuzz(self):
# Don't use fixed seed
np.random.seed()
for dt in self.itype[1:]:
for ubnd in [4, 8, 16]:
vals = self.rfunc(2, ubnd, size=2**16, dtype=dt)
assert_(vals.max() < ubnd)
assert_(vals.min() >= 2)
vals = self.rfunc(0, 2, size=2**16, dtype=np.bool_)
assert_(vals.max() < 2)
assert_(vals.min() >= 0)
def test_repeatability(self):
See More Examples