Beispiel #1
0
def spawn_symbol(cfg, coord, rnd_dist, nscales):
    dest = coord + utils.sample_unit_sphere(rnd_dist)

    # check not to spawn a symbol outside the environment
    while np.linalg.norm(dest) >= cfg.world_radius:
        dest = coord + utils.sample_unit_sphere(rnd_dist)

    return modules.Symbol(dest, nscales)
Beispiel #2
0
 def initialize_weights(self, method):
     if method == "zero":
         return zeros(self.feature_count)
     elif method == "random":
         return sample_unit_sphere(self.feature_count) * 0.01
     elif method == "fullyrandom":
         v = zeros(self.feature_count)
         for i in range(self.feature_count):
             v[i] = gauss(0, 1)
         return v
     else:
         try:
             weights = array([float(num) for num in method.split(",")])
             if len(weights) != self.feature_count:
                 raise Exception(
                     "List of initial weights does not have the"
                     " expected length (%d, expected $d)." % (len(weights, self.feature_count))
                 )
             return weights
         except Exception as ex:
             raise Exception(
                 "Could not parse weight initialization method:"
                 " %s. Possible values: zero, random, or a comma-separated "
                 "list of float values that indicate specific weight values"
                 ". Error: %s" % (method, ex)
             )
Beispiel #3
0
 def initialize_weights(self, method):
     if method == "zero":
         return zeros(self.feature_count)
     elif method == "random":
         return sample_unit_sphere(self.feature_count) * 0.01
     elif method == "fullyrandom":
         v = zeros(self.feature_count)
         for i in range(self.feature_count):
             v[i] = gauss(0, 1)
         return v
     else:
         try:
             weights = array([float(num) for num in method.split(",")])
             if len(weights) != self.feature_count:
                 raise Exception("List of initial weights does not have the"
                                 " expected length (%d, expected $d)." %
                                 (len(weights, self.feature_count)))
             return weights
         except Exception as ex:
             raise Exception(
                 "Could not parse weight initialization method:"
                 " %s. Possible values: zero, random, or a comma-separated "
                 "list of float values that indicate specific weight values"
                 ". Error: %s" % (method, ex))
Beispiel #4
0
 def initialize_weights(self, init_method):
     if init_method == "random":
         return sample_unit_sphere(self.feature_count)
     return np.array([2.5, 0, 0.8])