Exemplo n.º 1
0
Arquivo: mapp.py Projeto: afcarl/isa
    def run(function, queue, indices, rseed, *args):
        # randomize
        np_seed(rseed)
        py_seed(rseed)

        # compute and store results
        queue.put(dict(zip(indices, map(function, *args))))
Exemplo n.º 2
0
    def run(function, queue, idx, rnd, *args):
        """
		A helper function for handling return values. Takes a function and its
		arguments and stores its result in a queue.

		@type  function: function
		@param function: handle to function that will be called

		@type  queue: Queue
		@param queue: stores returned function values

		@type  idx: integer
		@param idx: index used to identify return values

		@type  rnd: float
		@param rnd: a random number to seed random number generator
		"""

        # compute random seed
        rnd_seed = int(1e6 * rnd + 1e6 * time())

        # without it, different processes are likely to use the same seed
        numpy_seed(rnd_seed)
        py_seed(rnd_seed)

        # evaluate function
        queue.put((idx, function(*args)))
Exemplo n.º 3
0
	def run(function, queue, indices, rseed, *args):
		# randomize
		np_seed(rseed)
		py_seed(rseed)

		# compute and store results
		queue.put(dict(zip(indices, map(function, *args))))
	def run(function, queue, idx, rnd, *args):
		"""
		A helper function for handling return values. Takes a function and its
		arguments and stores its result in a queue.

		@type  function: function
		@param function: handle to function that will be called

		@type  queue: Queue
		@param queue: stores returned function values

		@type  idx: integer
		@param idx: index used to identify return values

		@type  rnd: float
		@param rnd: a random number to seed random number generator
		"""

		# compute random seed
		rnd_seed = int(1e6 * rnd + 1e6 * time())

		# without it, different processes are likely to use the same seed
		numpy_seed(rnd_seed)
		py_seed(rnd_seed)

		# evaluate function
		queue.put((idx, function(*args)))
Exemplo n.º 5
0
def set_seeds():
    # set all random seeds
    import tensorflow as tf
    from numpy.random import seed as np_seed
    from random import seed as py_seed
    from snorkel.utils import set_seed as snork_seed
    snork_seed(123)
    tf.random.set_seed(123)
    np_seed(123)
    py_seed(123)